[pacman-dev] [PATCH] Change download functions to handle funny urls

Henning Garus henning.garus at googlemail.com
Thu Jul 31 18:59:14 EDT 2008


Stop urls containing & or ? from breaking get_downloadclient()
and get_downloadcmd().

Fixes FS#11076

Signed-off-by: Henning Garus <henning.garus at 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





More information about the pacman-dev mailing list