Skip to content

Commit

Permalink
Catch situation where Regex flag fails (CTFd#1426)
Browse files Browse the repository at this point in the history
* Catch an exception where a user supplied regex Flag can fail to parse
* Starts on CTFd#1425
  • Loading branch information
ColdHeat authored May 20, 2020
1 parent ba887e8 commit d3f8441
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions CTFd/plugins/flags/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ def compare(chal_key_obj, provided):
saved = chal_key_obj.content
data = chal_key_obj.data

if data == "case_insensitive":
res = re.match(saved, provided, re.IGNORECASE)
else:
res = re.match(saved, provided)
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

Expand Down

0 comments on commit d3f8441

Please sign in to comment.