[pacman-dev] makepkg download fails with special chars in URL (was: [signoff] pacman 3.2.0)

Allan McRae allan at archlinux.org
Thu Jul 31 09:58:54 EDT 2008


Dan McGee wrote:
> On Thu, Jul 31, 2008 at 8:15 AM, Xavier <shiningxc at gmail.com> wrote:
>   
>> On Thu, Jul 31, 2008 at 2:50 PM, Allan McRae <allan at archlinux.org> wrote:
>>     
>>>> Indeed, that is the first problem, netfile should be quoted here.
>>>> local proto=$(echo "$netfile" | sed 's|://.*||')
>>>>
>>>>
>>>>         
>>> And that $netfile should be $url....
>>>
>>>       
>> Yeah, apparently.
>>
>>     
>>>> But once this is fixed, we run into a second problem, with another sed
>>>> command, which breaks because of all the & in the url.
>>>>  local dlcmd=$(echo "$dlagent" | sed "s|%o|$file.part|" | sed "s|%u|$netfile|"
>>>>
>>>> $ netfile="ab&cd&ef"; echo "%u" | sed "s|%u|$netfile|"
>>>> ab%ucd%uef
>>>>
>>>> $ netfile="ab\&cd\&ef"; echo "%u" | sed "s|%u|$netfile|"
>>>> ab&cd&ef
>>>>
>>>> So I don't see how to fix this except manually escaping all & in the url...
>>>>
>>>>         
>>> Well, to just make the bug more obscure.
>>>
>>> $ netfile="ab&cd&ef"; echo "%u" | sed "s|%u|$netfile|" | sed "s|\%u|\&|g"
>>> ab&cd&ef
>>>
>>> But that makes problems if there is a %u in the url.  But can we do some
>>> multistage hackery like that?
>>>
>>>       
>> I really don't like this.
>>
>> I think we could use bash feature instead.
>> echo ${netfile//foo/bar}
>>     

I went for this approach:
local netfile=$(echo "$2" | sed "s|\&|\\\&|g")


>> But even after converting the two above sed rules with this, I still
>> have other problem. It is driving me crazy.
>> When I print the whole download command myself, and copy/paste it to
>> the shell, it works fine.
>> But when it gets executed in makepkg with : $(get_downloadcmd foo
>> bar), it always fail.
>>     
>
>   

I'm stuck there too...

> Subject change...and can someone open a bug and get this information
> in there, please? I'd rather track it there before 10 other people
> complain too.
>   

Filing bug report now.

Allan






More information about the pacman-dev mailing list