[Twisted-web] fix nevow exception in args parsing

Andrea Arcangeli andrea at cpushare.com
Sun Sep 4 21:03:56 MDT 2005


On Sat, Sep 03, 2005 at 12:11:58PM +0100, Matt Goodall wrote:
> 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.

You're welcome! I agree this is more correct (and hopefully all code
knows that "=" can be inside the argument ;).



More information about the Twisted-web mailing list