diff --git a/backend/forms.py b/backend/forms.py index faf1ad2a..3abb2e55 100644 --- a/backend/forms.py +++ b/backend/forms.py @@ -75,7 +75,7 @@ class StringDictKeyValue(StringField): # Remove empty strings cleaned = list(filter(None, valuelist[0].split("\n"))) for s in cleaned: - parts = s.strip().split(':') + parts = s.strip().split(':', 1) if len(parts) == 2: self.data.update({parts[0].strip(): parts[1].strip()}) diff --git a/backend/tests/test_headers.py b/backend/tests/test_headers.py index 3e4a0079..420fd39f 100644 --- a/backend/tests/test_headers.py +++ b/backend/tests/test_headers.py @@ -26,6 +26,8 @@ def test_headers_in_request(client, live_server): ) assert b"1 Imported" in res.data + cookie_header = '_ga=GA1.2.1022228332; cookie-preferences=analytics:accepted;' + # Add some headers to a request res = client.post( @@ -33,7 +35,7 @@ def test_headers_in_request(client, live_server): data={ "url": test_url, "tag": "", - "headers": "xxx:ooo\ncool:yeah\r\n"}, + "headers": "xxx:ooo\ncool:yeah\r\ncookie:"+cookie_header}, follow_redirects=True ) assert b"Updated watch." in res.data @@ -52,6 +54,10 @@ def test_headers_in_request(client, live_server): assert b"Xxx:ooo" in res.data assert b"Cool:yeah" in res.data + # The test call service will return the headers as the body + from html import escape + assert escape(cookie_header).encode('utf-8') in res.data + time.sleep(5) # Re #137 - Examine the JSON index file, it should have only one set of headers entered