Re #172 - be sure that we are non-greedy matching the first : when splitting the headers so we dont break "Cookie" header (#175)

pull/114/head
dgtlmoon 3 years ago committed by GitHub
parent dd193ffcec
commit f88561e713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -75,7 +75,7 @@ class StringDictKeyValue(StringField):
# Remove empty strings # Remove empty strings
cleaned = list(filter(None, valuelist[0].split("\n"))) cleaned = list(filter(None, valuelist[0].split("\n")))
for s in cleaned: for s in cleaned:
parts = s.strip().split(':') parts = s.strip().split(':', 1)
if len(parts) == 2: if len(parts) == 2:
self.data.update({parts[0].strip(): parts[1].strip()}) self.data.update({parts[0].strip(): parts[1].strip()})

@ -26,6 +26,8 @@ def test_headers_in_request(client, live_server):
) )
assert b"1 Imported" in res.data assert b"1 Imported" in res.data
cookie_header = '_ga=GA1.2.1022228332; cookie-preferences=analytics:accepted;'
# Add some headers to a request # Add some headers to a request
res = client.post( res = client.post(
@ -33,7 +35,7 @@ def test_headers_in_request(client, live_server):
data={ data={
"url": test_url, "url": test_url,
"tag": "", "tag": "",
"headers": "xxx:ooo\ncool:yeah\r\n"}, "headers": "xxx:ooo\ncool:yeah\r\ncookie:"+cookie_header},
follow_redirects=True follow_redirects=True
) )
assert b"Updated watch." in res.data 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"Xxx:ooo" in res.data
assert b"Cool:yeah" 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) time.sleep(5)
# Re #137 - Examine the JSON index file, it should have only one set of headers entered # Re #137 - Examine the JSON index file, it should have only one set of headers entered

Loading…
Cancel
Save