File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -404,11 +404,11 @@ def _parse_urlencoded(self, urlencoded):
404
404
if len (urlencoded ) > 0 :
405
405
if isinstance (urlencoded , str ):
406
406
for k , v in [pair .split ('=' , 1 )
407
- for pair in urlencoded .split ('&' )]:
407
+ for pair in urlencoded .split ('&' ) if pair ]:
408
408
data [urldecode_str (k )] = urldecode_str (v )
409
409
elif isinstance (urlencoded , bytes ): # pragma: no branch
410
410
for k , v in [pair .split (b'=' , 1 )
411
- for pair in urlencoded .split (b'&' )]:
411
+ for pair in urlencoded .split (b'&' ) if pair ]:
412
412
data [urldecode_bytes (k )] = urldecode_bytes (v )
413
413
return data
414
414
Original file line number Diff line number Diff line change @@ -45,6 +45,13 @@ def test_args(self):
45
45
self .assertEqual (req .args , MultiDict (
46
46
{'foo' : 'bar' , 'abc' : 'def' , 'x' : '/%%' }))
47
47
48
+ def test_badly_formatted_args (self ):
49
+ fd = get_request_fd ('GET' , '/?&foo=bar&abc=def&&&x=%2f%%' )
50
+ req = Request .create ('app' , fd , 'addr' )
51
+ self .assertEqual (req .query_string , '&foo=bar&abc=def&&&x=%2f%%' )
52
+ self .assertEqual (req .args , MultiDict (
53
+ {'foo' : 'bar' , 'abc' : 'def' , 'x' : '/%%' }))
54
+
48
55
def test_json (self ):
49
56
fd = get_request_fd ('GET' , '/foo' , headers = {
50
57
'Content-Type' : 'application/json' }, body = '{"foo":"bar"}' )
You can’t perform that action at this time.
0 commit comments