Add re.escape to highlight_string

This commit is contained in:
kkthxbye-code 2023-01-17 18:16:10 +01:00 committed by Jeremy Stretch
parent 9e09e46700
commit df5febf6e7

View File

@ -517,7 +517,7 @@ def highlight_string(value, highlight, trim_pre=None, trim_post=None, trim_place
""" """
# Split value on highlight string # Split value on highlight string
try: try:
pre, match, post = re.split(fr'({highlight})', value, maxsplit=1, flags=re.IGNORECASE) pre, match, post = re.split(fr'({re.escape(highlight)})', value, maxsplit=1, flags=re.IGNORECASE)
except ValueError: except ValueError:
# Match not found # Match not found
return escape(value) return escape(value)