Browse Source

For webhook integration, validate each header line separately

pull/320/head
Pēteris Caune 5 years ago
parent
commit
be286518b7
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
3 changed files with 4 additions and 3 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -1
      hc/front/forms.py
  3. +2
    -2
      hc/front/tests/test_add_webhook.py

+ 1
- 0
CHANGELOG.md View File

@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
- Don't set CSRF cookie on first visit. Signup is exempt from CSRF protection
- Fix List-Unsubscribe email header value: add angle brackets
- Unsubscribe links serve a form, and require HTTP POST to actually unsubscribe
- For webhook integration, validate each header line separately
## v1.11.0 - 2019-11-22


+ 1
- 1
hc/front/forms.py View File

@ -27,7 +27,7 @@ class HeadersField(forms.Field):
if not line.strip():
continue
if ":" not in value:
if ":" not in line:
raise ValidationError(self.message)
n, v = line.split(":", maxsplit=1)


+ 2
- 2
hc/front/tests/test_add_webhook.py View File

@ -122,12 +122,12 @@ class AddWebhookTestCase(BaseTestCase):
form = {
"method_down": "GET",
"url_down": "http://example.org",
"headers_down": "invalid-headers",
"headers_down": "invalid-header\nfoo:bar",
"method_up": "GET",
}
r = self.client.post(self.url, form)
self.assertContains(r, """invalid-headers""")
self.assertContains(r, """invalid-header""")
self.assertEqual(Channel.objects.count(), 0)
def test_it_strips_headers(self):


Loading…
Cancel
Save