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):
404404 if len (urlencoded ) > 0 :
405405 if isinstance (urlencoded , str ):
406406 for k , v in [pair .split ('=' , 1 )
407- for pair in urlencoded .split ('&' )]:
407+ for pair in urlencoded .split ('&' ) if pair ]:
408408 data [urldecode_str (k )] = urldecode_str (v )
409409 elif isinstance (urlencoded , bytes ): # pragma: no branch
410410 for k , v in [pair .split (b'=' , 1 )
411- for pair in urlencoded .split (b'&' )]:
411+ for pair in urlencoded .split (b'&' ) if pair ]:
412412 data [urldecode_bytes (k )] = urldecode_bytes (v )
413413 return data
414414
Original file line number Diff line number Diff line change @@ -45,6 +45,13 @@ def test_args(self):
4545 self .assertEqual (req .args , MultiDict (
4646 {'foo' : 'bar' , 'abc' : 'def' , 'x' : '/%%' }))
4747
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+
4855 def test_json (self ):
4956 fd = get_request_fd ('GET' , '/foo' , headers = {
5057 'Content-Type' : 'application/json' }, body = '{"foo":"bar"}' )
You can’t perform that action at this time.
0 commit comments