Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Commit

Permalink
Escape user-provided text passed to regex
Browse files Browse the repository at this point in the history
Rather than using the user/document-provided values directly, we instead
escape them to use them verbatim.

This fixes issue #568.
  • Loading branch information
pitkley committed Feb 23, 2020
1 parent e0da952 commit 989af90
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/documents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ def _split_match(self):
findterms = re.compile(r'"([^"]+)"|(\S+)').findall
normspace = re.compile(r"\s+").sub
return [
normspace(" ", (t[0] or t[1]).strip()).replace(" ", r"\s+")
re.escape(
normspace(" ", (t[0] or t[1]).strip())
).replace(r"\ ", "\s+")
for t in findterms(self.match)
]

Expand Down

0 comments on commit 989af90

Please sign in to comment.