1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

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
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:
# Match not found
return escape(value)