mirror of https://gitlab.com/bashrc2/epicyon
Add unit test for Lynx browser POST
parent
9b5f638bee
commit
3dd4debf24
|
@ -1497,6 +1497,7 @@ def extract_text_fields_in_post(post_bytes, boundary: str, debug: bool,
|
|||
)
|
||||
if debug:
|
||||
print('DEBUG: POST message_fields: ' + str(message_fields))
|
||||
lynx_content_type = 'Content-Type: text/plain; charset=utf-8'
|
||||
# examine each section of the POST, separated by the boundary
|
||||
for fld in message_fields:
|
||||
if fld == '--':
|
||||
|
@ -1508,6 +1509,9 @@ def extract_text_fields_in_post(post_bytes, boundary: str, debug: bool,
|
|||
continue
|
||||
post_key = post_str.split('"', 1)[0]
|
||||
post_value_str = post_str.split('"', 1)[1]
|
||||
if boundary == '--LYNX':
|
||||
post_value_str = \
|
||||
post_value_str.replace(lynx_content_type, '')
|
||||
if ';' in post_value_str:
|
||||
if post_key not in fields_with_semicolon_allowed and \
|
||||
not post_key.startswith('edited'):
|
||||
|
|
12
tests.py
12
tests.py
|
@ -5852,6 +5852,18 @@ def _test_extract_text_fields_from_post():
|
|||
assert fields['imageDescription'] == ''
|
||||
assert fields['message'] == 'This is a ; test'
|
||||
|
||||
boundary = '--LYNX'
|
||||
form_data = '--LYNX\r\nContent-Disposition: form-data; ' + \
|
||||
'name="fieldName"\r\nContent-Type: text/plain; ' + \
|
||||
'charset=utf-8\r\nThis is a lynx test\r\n--LYNX\r\n' + \
|
||||
'Content-Disposition: form-data; name="submitYes"\r\n' + \
|
||||
'Content-Type: text/plain; charset=utf-8\r\nBUTTON\r\n--LYNX--\r\n'
|
||||
debug = True
|
||||
fields = extract_text_fields_in_post(None, boundary, debug, form_data)
|
||||
print('fields: ' + str(fields))
|
||||
assert fields['fieldName'] == 'This is a lynx test'
|
||||
assert fields['submitYes'] == 'BUTTON'
|
||||
|
||||
|
||||
def _test_speaker_replace_link():
|
||||
print('testSpeakerReplaceLinks')
|
||||
|
|
Loading…
Reference in New Issue