Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

[fix] server side error: escape backslashes in the query highlight_content

Solirsfbb0e9d27509
diff --git a/searx/webutils.py b/searx/webutils.py
index 7b9a8045c..6c023ebc3 100644
--- a/searx/webutils.py
+++ b/searx/webutils.py
@@ -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