diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-16 16:47:15 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-16 16:47:15 +0200 |
commit | e18e05cce92182e7f852e2d1569904190b8a9a40 (patch) | |
tree | 6a9b85ad22229c378de5f57e579c8b2296d5c5b0 /Lib/sre_parse.py | |
parent | 94bf697b01f56b99bfd3edaf72b7f4893d80c122 (diff) | |
download | cpython-git-e18e05cce92182e7f852e2d1569904190b8a9a40.tar.gz |
Issue #13169: The maximal repetition number in a regular expression has been
increased from 65534 to 2147483647 (on 32-bit platform) or 4294967294 (on
64-bit).
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r-- | Lib/sre_parse.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 8b98b1ac2e..a0cf34414b 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -15,6 +15,7 @@ import sys from sre_constants import * +from _sre import MAXREPEAT SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" @@ -498,10 +499,14 @@ def _parse(source, state): continue if lo: min = int(lo) + if min >= MAXREPEAT: + raise OverflowError("the repetition number is too large") if hi: max = int(hi) - if max < min: - raise error, "bad repeat interval" + if max >= MAXREPEAT: + raise OverflowError("the repetition number is too large") + if max < min: + raise error("bad repeat interval") else: raise error, "not supported" # figure out which item to repeat |