summaryrefslogtreecommitdiffstats
path: root/Lib/sre_parse.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-16 14:54:33 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-16 14:54:33 (GMT)
commita0eb80999538febe046164bae541d3f07b899dfb (patch)
tree05b2bdfb56f6ef914c35602f5b4813f645f7abb7 /Lib/sre_parse.py
parent293ab9728aafc86e33b268049ce598dccf56ff51 (diff)
parent70ca0210e8958d2665541ddd38fce2965075674e (diff)
downloadcpython-a0eb80999538febe046164bae541d3f07b899dfb.zip
cpython-a0eb80999538febe046164bae541d3f07b899dfb.tar.gz
cpython-a0eb80999538febe046164bae541d3f07b899dfb.tar.bz2
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.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
index 1298d48..b195fd0 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