Skip to content

Commit

Permalink
Add bad header that caused catastrophic backtracking
Browse files Browse the repository at this point in the history
This lets us validate that we won't accidentally cause the same issue
down the line if we mess with the regular expressions
  • Loading branch information
digitalresistor committed Feb 2, 2020
1 parent 2fe8e54 commit f87abb7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions waitress/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,17 @@ def test_parse_header_multiple_values_extra_space(self):
self.assertIn("FOO", self.parser.headers)
self.assertEqual(self.parser.headers["FOO"], "abrowser/0.001 (C O M M E N T)")

def test_parse_header_invalid_backtrack_bad(self):
from waitress.parser import ParsingError

data = b"GET /foobar HTTP/1.1\r\nfoo: bar\r\nfoo: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\x10\r\n"
try:
self.parser.parse_header(data)
except ParsingError as e:
self.assertIn("Invalid header", e.args[0])
else: # pragma: nocover
self.assertTrue(False)

def test_parse_header_short_values(self):
from waitress.parser import ParsingError

Expand Down

0 comments on commit f87abb7

Please sign in to comment.