cpython: d40afd489b6a (original) (raw)

Mercurial > cpython

changeset 82227:d40afd489b6a 3.2

Issue #9669: Protect re against infinite loops on zero-width matching in non-greedy repeat. Patch by Matthew Barnett. [#9669]

Serhiy Storchaka storchaka@gmail.com
date Sat, 16 Feb 2013 21:23:53 +0200
parents 472a7c652cbd
children 8f9b628593db a6231ed7bff4
files Lib/test/test_re.py Misc/NEWS Modules/_sre.c
diffstat 3 files changed, 19 insertions(+), 2 deletions(-)[+] [-] Lib/test/test_re.py 9 Misc/NEWS 3 Modules/_sre.c 9

line wrap: on

line diff

--- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -616,6 +616,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_scanner(self): def s_ident(scanner, token): return token def s_operator(scanner, token): return "op%s" % token

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -224,6 +224,9 @@ Core and Builtins Library ------- +- Issue #9669: Protect re against infinite loops on zero-width matching in

--- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -1295,13 +1295,18 @@ entrance: LASTMARK_RESTORE();

ctx->u.rep->count = ctx->count;