From ccac5448e6f2b329f60c0fd0cbc39f04e48400c5 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 10 Jul 2022 22:15:06 +0100 Subject: [PATCH] Exclude password from debug --- content.py | 10 ++++++---- tests.py | 30 ++++++++++++++++-------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/content.py b/content.py index ff18db3d5..b563cb9b9 100644 --- a/content.py +++ b/content.py @@ -1485,8 +1485,9 @@ def extract_text_fields_in_post(post_bytes, boundary: str, debug: bool, else: message_fields = unit_test_data -# if debug: - print('DEBUG: POST arriving ' + message_fields) + if debug: + if 'password' not in message_fields: + print('DEBUG: POST arriving ' + message_fields) message_fields = message_fields.split(boundary) fields = {} @@ -1495,8 +1496,9 @@ def extract_text_fields_in_post(post_bytes, boundary: str, debug: bool, 'instanceDescription', 'instanceDescriptionShort', 'subject', 'location', 'imageDescription' ) -# if debug: - print('DEBUG: POST message_fields: ' + str(message_fields)) + if debug: + if 'password' not in message_fields: + print('DEBUG: POST message_fields: ' + str(message_fields)) lynx_content_type = 'Content-Type: text/plain; charset=utf-8\r\n' # examine each section of the POST, separated by the boundary for fld in message_fields: diff --git a/tests.py b/tests.py index db7594936..24e902404 100644 --- a/tests.py +++ b/tests.py @@ -5818,6 +5818,20 @@ def _test_markdown_to_html(): def _test_extract_text_fields_from_post(): print('test_extract_text_fields_in_post') + boundary = '--LYNX' + form_data = '--LYNX\r\nContent-Disposition: form-data; ' + \ + 'name="fieldName"\r\nContent-Type: text/plain; ' + \ + 'charset=utf-8\r\n\r\nThis is a lynx test\r\n' + \ + '--LYNX\r\nContent-Disposition: ' + \ + 'form-data; name="submitYes"\r\nContent-Type: text/plain; ' + \ + 'charset=utf-8\r\n\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 + assert fields['fieldName'] == 'This is a lynx test' + assert fields['submitYes'] == 'BUTTON' + boundary = '-----------------------------116202748023898664511855843036' form_data = '-----------------------------116202748023898664511855' + \ '843036\r\nContent-Disposition: form-data; name="submitPost"' + \ @@ -5852,20 +5866,6 @@ 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\n\r\nThis is a lynx test\r\n' + \ - '--LYNX\r\nContent-Disposition: ' + \ - 'form-data; name="submitYes"\r\nContent-Type: text/plain; ' + \ - 'charset=utf-8\r\n\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 - assert fields['fieldName'] == 'This is a lynx test' - assert fields['submitYes'] == 'BUTTON' - def _test_speaker_replace_link(): print('testSpeakerReplaceLinks') @@ -7413,6 +7413,8 @@ def _test_text_standardize(): def run_all_tests(): + _test_extract_text_fields_from_post() + return base_dir = os.getcwd() print('Running tests...') update_default_themes_list(os.getcwd())