[pacman-dev] [PATCH] Change download functions to handle funny urls
Stop urls containing & or ? from breaking get_downloadclient() and get_downloadcmd(). Fixes FS#11076 Signed-off-by: Henning Garus <henning.garus@gmail.com> --- scripts/makepkg.sh.in | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 041b460..38364a6 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -256,7 +256,7 @@ in_array() { get_downloadclient() { # $1 = url with valid protocol prefix local url=$1 - local proto=$(echo $netfile | sed 's|://.*||') + local proto=$(echo "$url" | sed 's|://.*||') # loop through DOWNLOAD_AGENTS variable looking for protocol local i @@ -293,7 +293,8 @@ get_downloadcmd() { local file=$3 if echo "$dlagent" | grep -q "%u" ; then - local dlcmd=$(echo "$dlagent" | sed "s|%o|$file.part|" | sed "s|%u|$netfile|") + #use awk because of possible & in $netfile (FS#11076) + local dlcmd=$(echo "$dlagent" | sed "s|%o|$file.part|" | awk -F "%u" -v nf="$netfile" '{ print $1 nf $2}') else local dlcmd="$dlagent $netfile" fi @@ -443,7 +444,10 @@ download_sources() { msg2 "$(gettext "Downloading %s...")" "$file" # fix flyspray bug #3289 local ret=0 + #disable expansion of possible ? in $netfile (FS#11076) + set -f $(get_downloadcmd "$dlclient" "$netfile" "$file") || ret=$? + set +f if [ $ret -gt 0 ]; then error "$(gettext "Failure while downloading %s")" "$file" plain "$(gettext "Aborting...")" -- 1.5.6.4
On Fri, Aug 1, 2008 at 12:59 AM, Henning Garus <henning.garus@googlemail.com> wrote:
Stop urls containing & or ? from breaking get_downloadclient() and get_downloadcmd().
Fixes FS#11076
Signed-off-by: Henning Garus <henning.garus@gmail.com>
Well we already discussed in private mails while the ML was down, so here is an extract for others : (my comment)
Now more on the technical side, your patch looks good to me, and it worked fine in my test, but I also found a decent alternative thanks to your help. The differences are usage of bash substitution instead of awk, and only enabling nullopt where it is needed, instead of disabling expansion. http://shining.toofishes.net/gitweb/gitweb.cgi?p=pacman.git;a=commitdiff;h=6... To be honest, I have no idea which way is best, so I will let you decide :)
(Henning's answer) For me using bash expansion looks saner than my awk hackery. Changing get_download_cmd() to download_file() looks good as well, so I would stick with your patch.
participants (2)
-
Henning Garus
-
Xavier