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

Commit 989af90

Browse files
committed
Escape user-provided text passed to regex
Rather than using the user/document-provided values directly, we instead escape them to use them verbatim. This fixes issue #568.
1 parent e0da952 commit 989af90

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/documents/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ def _split_match(self):
141141
findterms = re.compile(r'"([^"]+)"|(\S+)').findall
142142
normspace = re.compile(r"\s+").sub
143143
return [
144-
normspace(" ", (t[0] or t[1]).strip()).replace(" ", r"\s+")
144+
re.escape(
145+
normspace(" ", (t[0] or t[1]).strip())
146+
).replace(r"\ ", "\s+")
145147
for t in findterms(self.match)
146148
]
147149

0 commit comments

Comments
 (0)