mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Fix URL parameter decoding in web server (#3313)
* Make HTTP server test data easier to examine * Add HTTP server parameter tests containing & and = * Fix URL parameter decoding in web server The parameters string needs to be first split on & and =, and URL decoding on parts done after that. Otherwise URL encoded & and = within parameter names and values cause incorrect splitting.
This commit is contained in:
@ -24,7 +24,7 @@ def http_test(res, url, get=None, post=None):
|
||||
@setup('HTTP GET Parameters')
|
||||
def setup_http_get_params(e):
|
||||
def testRun():
|
||||
return http_test('var1=val with spaces&var+=some%', 'http://etd.local/get', {'var1' : 'val with spaces', 'var+' : 'some%'})
|
||||
return http_test('var1 = val with spaces\nva=r+ = so&me%', 'http://etd.local/get', {'var1' : 'val with spaces', 'va=r+' : 'so&me%'})
|
||||
Thread(target=testRun).start()
|
||||
|
||||
@teardown('HTTP GET Parameters')
|
||||
@ -34,7 +34,7 @@ def teardown_http_get_params(e):
|
||||
@setup('HTTP POST Parameters')
|
||||
def setup_http_post_params(e):
|
||||
def testRun():
|
||||
return http_test('var2=val with spaces', 'http://etd.local/post', None, {'var2' : 'val with spaces'})
|
||||
return http_test('var2 = val with spaces', 'http://etd.local/post', None, {'var2' : 'val with spaces'})
|
||||
Thread(target=testRun).start()
|
||||
|
||||
@teardown('HTTP POST Parameters')
|
||||
@ -44,7 +44,7 @@ def teardown_http_post_params(e):
|
||||
@setup('HTTP GET+POST Parameters')
|
||||
def setup_http_getpost_params(e):
|
||||
def testRun():
|
||||
return http_test('var3=val with spaces&var+=some%', 'http://etd.local/get_and_post', {'var3' : 'val with spaces'}, {'var+' : 'some%'})
|
||||
return http_test('var3 = val with spaces\nva&r+ = so=me%', 'http://etd.local/get_and_post', {'var3' : 'val with spaces'}, {'va&r+' : 'so=me%'})
|
||||
Thread(target=testRun).start()
|
||||
|
||||
@teardown('HTTP GET+POST Parameters')
|
||||
@ -63,7 +63,7 @@ def setup_http_upload(e):
|
||||
response = urllib2.urlopen(request, None, 2).read()
|
||||
except:
|
||||
return 1
|
||||
if response != 'test.txt:16&var4=val with spaces':
|
||||
if response != 'test.txt:16\nvar4 = val with spaces':
|
||||
return 1
|
||||
return 0
|
||||
Thread(target=testRun).start()
|
||||
|
Reference in New Issue
Block a user