GNU bug report logs -
#8706
24.0.50; [PATCH] Function to build a URL query-string
Previous Next
Reported by: Ian Eure <ian <at> simplegeo.com>
Date: Fri, 20 May 2011 18:40:02 UTC
Severity: wishlist
Tags: patch
Found in version 24.0.50
Done: Chong Yidong <cyd <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #29 received at 8706 <at> debbugs.gnu.org (full text, mbox):
On Tue, 7 Jun 2011 10:07:40 -0700 Ian Eure <ian <at> simplegeo.com> wrote:
IE> On May 25, 2011, at 1:31 PM, Ted Zlatanov wrote:
>> Single-element parameters, shown as just "key" instead of "key=val", are
>> a well-known URL query string convention. They are not opaque. I think
>> they should be explicitly supported.
>>
IE> As I said, they _are_ supported. You just have to explicitly pass an empty string in the pair:
(url-build-query-string '(("a" "b") ("c" "") (d)))
=> "a=b&c=&d="
IE> I believe this is the correct behavior.
You're right, it's not incorrect, but it's not optimal. The extra "="
can be safely omitted and it's preferrable to do so (for readability and
to save bytes). Maybe that could be optional behavior.
Also we could add an option to make ";" the separator (though the
default should still be "&").
IE> It's also precisely what url-parse-query-string returns:
IE> (url-parse-query-string "a=b&c=") -> (("c" "") ("a" "b"))
It's actually broken for valid URLs: (url-parse-query-string "a=b&c")
=> (("a" "b"))
Plus it doesn't support the ";" separator.
Ugh. Sorry to be a pain... but it's broken...
IE> Here's an updated patch which should correctly support everything
IE> url-parse-query-string produces. I also updated it to allow empty
IE> keys, as this was fairly easy with the code refactored to support
IE> (key val val val) syntax.
That all works great (I see it in the first example above).
Let me know how much of the above you want to do; I can implement all
the things I asked for if you're too busy. I appreciate your help.
Thanks
Ted
This bug report was last modified 13 years and 13 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.