]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
detect attempts to repeat anchors (fixes bug #130748)
authorFredrik Lundh <fredrik@pythonware.com>
Sun, 18 Feb 2001 21:04:48 +0000 (21:04 +0000)
committerFredrik Lundh <fredrik@pythonware.com>
Sun, 18 Feb 2001 21:04:48 +0000 (21:04 +0000)
Lib/sre_parse.py
Lib/test/re_tests.py

index 36036b6ecbee122cf83539505ed7c382ec30a5ab..3840365b8ef03dd055328aaa50161a4fb650d63d 100644 (file)
@@ -446,6 +446,7 @@ def _parse(source, state):
                 min, max = 0, 1
             elif this == "*":
                 min, max = 0, MAXREPEAT
+
             elif this == "+":
                 min, max = 1, MAXREPEAT
             elif this == "{":
@@ -475,6 +476,8 @@ def _parse(source, state):
             if subpattern:
                 item = subpattern[-1:]
             else:
+                item = None
+            if not item or (len(item) == 1 and item[0][0] == AT):
                 raise error, "nothing to repeat"
             if item[0][0] in (MIN_REPEAT, MAX_REPEAT):
                 raise error, "multiple repeat"
index 9daf8c4cdeb8d5faa57f1a4462872ed6ac614769..aacd916267c3610bf0630a05c0e8d98aa3021535 100755 (executable)
@@ -636,4 +636,6 @@ xyzabc
     (r'(?i)m+', 'MMM', SUCCEED, 'found', 'MMM'),
     (r'(?i)[M]+', 'MMM', SUCCEED, 'found', 'MMM'),
     (r'(?i)[m]+', 'MMM', SUCCEED, 'found', 'MMM'),
+    # bug 130748: ^* should be an error (nothing to repeat)
+    (r'^*', '', SYNTAX_ERROR),
 ]