Skip to content

Commit

Permalink
✅ Add ReDos check test (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo committed Feb 9, 2024
1 parent 0776bf0 commit c2eea36
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ def test_handles_ie6_bug(self):
t, p = parse_options_header(b'text/plain; filename="C:\\this\\is\\a\\path\\file.txt"')

self.assertEqual(p[b'filename'], b'file.txt')

def test_redos_attack_header(self):
t, p = parse_options_header(b'application/x-www-form-urlencoded; !="\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\')
# If vulnerable, this test wouldn't finish, the line above would hang
self.assertIn(b'"\\', p[b'!'])


class TestBaseParser(unittest.TestCase):
Expand Down

0 comments on commit c2eea36

Please sign in to comment.