Skip to content

Commit

Permalink
Merge pull request #2785 from ActiveState/mitchell/dx-2212
Browse files Browse the repository at this point in the history
Installer should check for an xml file by comparing the first few bytes instead of depending on `file`.
  • Loading branch information
mitchell-as authored Oct 3, 2023
2 parents c02d94a + 55d0070 commit 8dceb28
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions installers/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ ARCHIVE="$OS-amd64$DOWNLOADEXT"
$FETCH $INSTALLERTMPDIR/$ARCHIVE $STATEURL
# wget and curl differ on how to handle AWS' "Forbidden" result for unknown versions.
# wget will exit with nonzero status. curl simply creates an XML file with the forbidden error.
# If curl was used, make sure the file downloaded is of type 'data', according to the UNIX `file`
# command. (The XML error will be reported as a 'text' type.)
# If curl was used, make sure the file downloaded is not an XML file (i.e. it does not start with "<?xml").
# If wget returned an error or curl fetched a "forbidden" response, raise an error and exit.
if [ $? -ne 0 -o \( "`echo $FETCH | grep -o 'curl'`" = "curl" -a -z "`file -b $INSTALLERTMPDIR/$ARCHIVE | grep -o 'data'`" \) ]; then
if [ $? -ne 0 -o \( "`echo $FETCH | grep -o 'curl'`" = "curl" -a ! -z "`grep -o '^<?xml' $INSTALLERTMPDIR/$ARCHIVE`" \) ]; then
rm -f $INSTALLERTMPDIR/$ARCHIVE
progress_fail
error "Could not download the State Tool installer at $STATEURL. Please try again."
Expand Down

0 comments on commit 8dceb28

Please sign in to comment.