Keep blank URL parameters

TODO: This should probably be configurable
This commit is contained in:
Eric Entzel 2013-02-11 13:22:25 +11:00
parent 53792a5a28
commit 6bcf29c0ed
3 changed files with 5 additions and 3 deletions

View File

@ -67,7 +67,7 @@ def urldecode(s):
"""
Takes a urlencoded string and returns a list of (key, value) tuples.
"""
return cgi.parse_qsl(s)
return cgi.parse_qsl(s, keep_blank_values=True)
def urlencode(s):

View File

@ -58,7 +58,9 @@ class TestContentView:
d = utils.urlencode([("one", "two"), ("three", "four")])
v = cv.ViewURLEncoded()
assert v([], d, 100)
assert not v([], "foo", 100)
d = utils.urlencode([("adsfa", "")])
v = cv.ViewURLEncoded()
assert v([], d, 100)
def test_view_html(self):
v = cv.ViewHTML()

View File

@ -807,7 +807,7 @@ class TestRequest:
r = flow.Request(None, (1, 1), "host", 22, "https", "GET", "/?adsfa", h, "content")
q = r.get_query()
assert not q
assert q.lst == [("adsfa", "")]
r = flow.Request(None, (1, 1), "host", 22, "https", "GET", "/foo?x=y&a=b", h, "content")
assert r.get_query()