diff --git a/gestioncof/templatetags/utils.py b/gestioncof/templatetags/utils.py index 90855165..76bc6003 100644 --- a/gestioncof/templatetags/utils.py +++ b/gestioncof/templatetags/utils.py @@ -23,7 +23,7 @@ def key(d, key_name): def highlight_text(text, q): - q2 = "|".join(q.split()) + q2 = "|".join(re.escape(word) for word in q.split()) pattern = re.compile(r"(?P%s)" % q2, re.IGNORECASE) return mark_safe(re.sub(pattern, r"\g", diff --git a/kfet/templatetags/kfet_tags.py b/kfet/templatetags/kfet_tags.py index b3976326..c8b6a228 100644 --- a/kfet/templatetags/kfet_tags.py +++ b/kfet/templatetags/kfet_tags.py @@ -11,7 +11,7 @@ register = template.Library() def highlight_text(text, q): - q2 = "|".join(q.split()) + q2 = "|".join(re.escape(word) for word in q.split()) pattern = re.compile(r"(?P%s)" % q2, re.IGNORECASE) regex = r"\g" return mark_safe(re.sub(pattern, regex, text))