Catch situation where Regex flag fails (#1426)

* Catch an exception where a user supplied regex Flag can fail to parse
* Starts on #1425
This commit is contained in:
Kevin Chung
2020-05-20 19:24:58 -04:00
committed by GitHub
parent ba887e8952
commit d3f8441993

View File

@@ -49,10 +49,14 @@ class CTFdRegexFlag(BaseFlag):
saved = chal_key_obj.content
data = chal_key_obj.data
try:
if data == "case_insensitive":
res = re.match(saved, provided, re.IGNORECASE)
else:
res = re.match(saved, provided)
# TODO: this needs plugin improvements. See #1425.
except re.error:
return False
return res and res.group() == provided