[Twisted-web] fix nevow exception in args parsing

Matt Goodall matt at pollenation.net
Sat Sep 3 05:11:58 MDT 2005


Matt Goodall wrote:
> Andrea Arcangeli wrote:
> 
>>>I noticed an exception in nevow, for example with divmod.com/?=x=x=x.
>>>
>>>This is the fix, please apply this (or an equivalent one) to SVN:
>>>
>>>Index: Nevow/nevow/url.py
>>>===================================================================
>>>--- Nevow/nevow/url.py	(revision 1748)
>>>+++ Nevow/nevow/url.py	(working copy)
>>>@@ -21,7 +21,7 @@
>>> def _uqf(query):
>>>     for x in query.split('&'):
>>>         if '=' in x:
>>>-            yield tuple( [urllib.unquote_plus(s) for s in x.split('=')] )
>>>+            yield tuple( [urllib.unquote_plus(s) for s in x.split('=')[:2]] )
>>>         elif x:
>>>             yield (urllib.unquote_plus(x), None)
>>> unquerify = lambda query: list(_uqf(query))
> 
> 
> I don't think that's correct - it throws away information. A better
> solution is probably:
> 
>     yield tuple( [urllib.unquote_plus(s) for s in x.split('=', 1)] )
> 
> Do you agree? If so, I'll apply this fix later.

cgi.parse_qs agrees with me so I just committed my version of Andrea's
fix (with a test). Thanks for highlighting the error Andrea.

- Matt

-- 
     __
    /  \__     Matt Goodall, Pollenation Internet Ltd
    \__/  \    w: http://www.pollenation.net
  __/  \__/    e: matt at pollenation.net
 /  \__/  \    t: +44 (0)113 2252500
 \__/  \__/
 /  \	       Any views expressed are my own and do not necessarily
 \__/          reflect the views of my employer.



More information about the Twisted-web mailing list