Skip to content

Commit

Permalink
scripts/legal_info_html: Fix HTTP 301 Moved Permanently issue with li…
Browse files Browse the repository at this point in the history
…bxml2

The script checks for thw presence of the download sources.
When checking libxml2 ,HTTP 301 is returned with a relative location/path
on the same host. In fact it just complains about a missing '/' in the
URL. Assuming the location doesn't contain a protocol stop and validate
the original URL.


$ curl -IsS https://download.gnome.org/sources/libxml2/2.10
HTTP/2 301
server: nginx/1.24.0
content-type: text/html
location: /sources/libxml2/2.10/


$ curl -IsS https://download.gnome.org/sources/libxml2/2.10/
HTTP/2 200

Signed-off-by: Michael Hennerich <[email protected]>
  • Loading branch information
mhennerich committed Oct 11, 2023
1 parent 445d6e5 commit fc1494d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/legal_info_html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,13 @@ package_table_items () {
# We should use curl's -L, but then we couldn't track things
tmp=$(curl -IsS $url)
if [ $(echo "$tmp" | head -1 | grep -E "301|302" | wc -l) -gt 0 ] ; then
_url=$url
url=$(echo "$tmp" | grep -i "Location:" | awk '{print $2}' | sed -e 's/^[ \t]*//;s/[ \t]*$//')
url=${url%$'\r'}
if [[ $url != http* ]] ; then
url=$_url
break
fi
elif [ $(echo "$tmp" | head -1 | grep "404" | wc -l) -gt 0 ] ; then
url=$(echo $url | sed 's#/[^/]*$##' )
elif [ $(echo "$tmp" | head -1 | grep "200" | wc -l) -gt 0 ] ; then
Expand Down

0 comments on commit fc1494d

Please sign in to comment.