diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-16 16:55:54 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-16 16:55:54 +0200 |
commit | 165ee9645b6518f36c3ec23d0e64d2956e42c5c4 (patch) | |
tree | 30646ddd2223b92181f05b334089a8526a2e00fd /Lib/sre_parse.py | |
parent | 178e6fef9e8f6248dcc77022d0f448b33698ad8f (diff) | |
parent | a0eb80999538febe046164bae541d3f07b899dfb (diff) | |
download | cpython-git-165ee9645b6518f36c3ec23d0e64d2956e42c5c4.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 1298d48e6d..b195fd01dc 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 = "*+?{" @@ -537,10 +538,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 |