From 74275da92066b884a4d01d2a94c54c8c44410977 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 5 Aug 2026 12:37:32 +0200 Subject: [PATCH] fix: Detect encoded archive URL extensions (#2060) --- src/install.sh | 51 +++++++++++++++++++++----------------------------- src/mido.sh | 14 +++++++++++--- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/install.sh b/src/install.sh index 92a09c08..79074146 100644 --- a/src/install.sh +++ b/src/install.sh @@ -204,7 +204,7 @@ startInstall() { if [[ "${VERSION,,}" == "http"* ]]; then - file=$(basename "${VERSION%%\?*}") + file=$(basename "${VERSION%%[\?#]*}") printf -v file '%b' "${file//%/\\x}" file="${file//[!A-Za-z0-9._-]/_}" @@ -272,24 +272,6 @@ startInstall() { exit 50 fi - # Older releases stored the original download name in windows.base. New - # releases always store the final ISO name, so migrate legacy state once. - if [ -n "$previousBase" ] && [[ "${previousBase,,}" != *.iso ]]; then - - if isCompressed "$previousBase" || [[ "${previousBase,,}" == *.esd ]]; then - previousBase="${previousBase%.*}" - fi - - [ -n "$previousBase" ] || previousBase="download" - previousBase+=".iso" - - if ! writeState "base" "$previousBase"; then - error "Failed to migrate the previous installation state!" - exit 50 - fi - - fi - skipInstall "$BOOT" "$previousBase" && return 1 if [ -z "$previousBase" ] && hasDisk; then @@ -378,16 +360,7 @@ skipUnattended() { # Preserve custom media in place. Downloaded or reused media must be moved # back to persistent storage before the manual fallback is started. - if [ -n "$CUSTOM" ]; then - BOOT="$iso" - REMOVE="N" - else - if [[ "$iso" != "$BOOT" ]]; then - if ! mv -f "$iso" "$BOOT"; then - error "Failed to move ISO file: $iso" && return 1 - fi - fi - fi + useOriginalImage "$iso" finishInstall "$BOOT" "$aborted" "$boot" && return 0 return 1 @@ -417,10 +390,28 @@ skipInstall() { local iso="$1" local previousBase="$2" - local boot="$STORAGE/windows.boot" if [ -n "$previousBase" ]; then + + # Older releases stored the original download name in windows.base. New + # releases always store the final ISO name, so migrate legacy state once. + if [[ "${previousBase,,}" != *.iso ]]; then + + if isCompressed "$previousBase" || [[ "${previousBase,,}" == *.esd ]]; then + previousBase="${previousBase%.*}" + fi + + [ -n "$previousBase" ] || previousBase="download" + previousBase+=".iso" + + if ! writeState "base" "$previousBase"; then + error "Failed to migrate the previous installation state!" + exit 50 + fi + + fi + # A changed source invalidates an unfinished installation. Back up an # existing installation, but discard stale media when no disk exists yet. if [[ "${STORAGE,,}/${previousBase,,}" != "${iso,,}" ]]; then diff --git a/src/mido.sh b/src/mido.sh index 999e2046..26ad9142 100644 --- a/src/mido.sh +++ b/src/mido.sh @@ -1057,16 +1057,24 @@ getESD() { isCompressed() { - local url="${1%%\?*}" + local url="${1%%[\?#]*}" + local file + + file=$(basename "$url") + printf -v file '%b' "${file//%/\\x}" # The ReactOS latest-build endpoint returns an archive without a filename # extension, so recognize its path explicitly. - case "${url,,}" in + case "${file,,}" in *.7z | *.zip | *.rar | *.tar | *.cab | *.cpio | \ - *.lzh | *.lha | *.xar | */latest-x86-gcc-lin-rel ) + *.lzh | *.lha | *.xar ) return 0 ;; esac + case "${url,,}" in + */latest-x86-gcc-lin-rel ) return 0 ;; + esac + return 1 }