This commit is contained in:
parent
a334eefdf7
commit
30db5a4652
1 changed files with 4 additions and 3 deletions
|
@ -15,9 +15,10 @@ def isSafePattern(pattern):
|
||||||
if unsafe_pattern_match:
|
if unsafe_pattern_match:
|
||||||
raise UnsafePatternError("Potentially unsafe part of the pattern: %s in %s" % (unsafe_pattern_match.group(0), pattern))
|
raise UnsafePatternError("Potentially unsafe part of the pattern: %s in %s" % (unsafe_pattern_match.group(0), pattern))
|
||||||
|
|
||||||
repetitions = re.findall(r"\.[\*\{\+]", pattern)
|
repetitions1 = re.findall(r"\.[\*\{\+]", pattern)
|
||||||
if len(repetitions) >= 10:
|
repetitions2 = re.findall(r"[^(][?]", pattern)
|
||||||
raise UnsafePatternError("More than 10 repetitions of %s in %s" % (repetitions[0], pattern))
|
if len(repetitions1) + len(repetitions2) >= 10:
|
||||||
|
raise UnsafePatternError("More than 10 repetitions in %s" % pattern)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue