mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 22:44:24 +01:00
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:
@@ -49,10 +49,14 @@ class CTFdRegexFlag(BaseFlag):
|
|||||||
saved = chal_key_obj.content
|
saved = chal_key_obj.content
|
||||||
data = chal_key_obj.data
|
data = chal_key_obj.data
|
||||||
|
|
||||||
|
try:
|
||||||
if data == "case_insensitive":
|
if data == "case_insensitive":
|
||||||
res = re.match(saved, provided, re.IGNORECASE)
|
res = re.match(saved, provided, re.IGNORECASE)
|
||||||
else:
|
else:
|
||||||
res = re.match(saved, provided)
|
res = re.match(saved, provided)
|
||||||
|
# TODO: this needs plugin improvements. See #1425.
|
||||||
|
except re.error:
|
||||||
|
return False
|
||||||
|
|
||||||
return res and res.group() == provided
|
return res and res.group() == provided
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user