Merge pull request #2257 from Solirs/fix_bad_escape

re.escape() the query in highlight_content to prevent a server side error.
This commit is contained in:
Markus Heiser 2023-03-17 08:54:54 +01:00 committed by GitHub
commit 677903c355
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -174,7 +174,9 @@ def highlight_content(content, query):
queries.extend(re.findall(regex_highlight_cjk(qs), content, flags=re.I | re.U))
if len(queries) > 0:
for q in set(queries):
content = re.sub(regex_highlight_cjk(q), f'<span class="highlight">{q}</span>', content)
content = re.sub(
regex_highlight_cjk(q), f'<span class="highlight">{q}</span>'.replace('\\', r'\\'), content
)
return content