forked from DGNum/gestioCOF
Escape the content of the regex in highligh_text
This commit is contained in:
parent
4899bba1f7
commit
dc50a23b10
2 changed files with 2 additions and 2 deletions
|
@ -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<filter>%s)" % q2, re.IGNORECASE)
|
||||
return mark_safe(re.sub(pattern,
|
||||
r"<span class='highlight'>\g<filter></span>",
|
||||
|
|
|
@ -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<filter>%s)" % q2, re.IGNORECASE)
|
||||
regex = r"<span class='highlight_autocomplete'>\g<filter></span>"
|
||||
return mark_safe(re.sub(pattern, regex, text))
|
||||
|
|
Loading…
Reference in a new issue