diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-16 19:25:05 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-16 19:25:05 (GMT) |
commit | b0c75a7dec2ae9d514ac8df63a4822215e486e1f (patch) | |
tree | 3a95c5e15ada6a2fa4613dcb6a6d2336723c25ba /Lib/test/test_re.py | |
parent | f8def28ff03f3167bd0becabab4dc5d70ee22033 (diff) | |
parent | fa4681691591429466d18e21d7640e3703ab7f28 (diff) | |
download | cpython-b0c75a7dec2ae9d514ac8df63a4822215e486e1f.zip cpython-b0c75a7dec2ae9d514ac8df63a4822215e486e1f.tar.gz cpython-b0c75a7dec2ae9d514ac8df63a4822215e486e1f.tar.bz2 |
Issue #9669: Protect re against infinite loops on zero-width matching in
non-greedy repeat. Patch by Matthew Barnett.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r-- | Lib/test/test_re.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 9346f8b..f96c3f9 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -681,6 +681,15 @@ class ReTests(unittest.TestCase): self.assertEqual(re.match('(x)*y', 50000*'x'+'y').group(1), 'x') self.assertEqual(re.match('(x)*?y', 50000*'x'+'y').group(1), 'x') + def test_unlimited_zero_width_repeat(self): + # Issue #9669 + self.assertIsNone(re.match(r'(?:a?)*y', 'z')) + self.assertIsNone(re.match(r'(?:a?)+y', 'z')) + self.assertIsNone(re.match(r'(?:a?){2,}y', 'z')) + self.assertIsNone(re.match(r'(?:a?)*?y', 'z')) + self.assertIsNone(re.match(r'(?:a?)+?y', 'z')) + self.assertIsNone(re.match(r'(?:a?){2,}?y', 'z')) + def test_scanner(self): def s_ident(scanner, token): return token def s_operator(scanner, token): return "op%s" % token |