Преглед на файлове

HUE-5213 [metadata] Protect against matching terms with regexp syntax in search

Romain Rigaux преди 9 години
родител
ревизия
a98815affa
променени са 2 файла, в които са добавени 3 реда и са изтрити 0 реда
  1. 1 0
      desktop/libs/metadata/src/metadata/navigator_api.py
  2. 2 0
      desktop/libs/metadata/src/metadata/navigator_client_tests.py

+ 1 - 0
desktop/libs/metadata/src/metadata/navigator_api.py

@@ -268,6 +268,7 @@ def _augment_highlighting(query_s, records):
 
 
 def _highlight(pattern, string):
+  pattern = re.escape(pattern)
   return re.sub('(%s)' % pattern, '<em>\\1</em>', string, count=1)
 
 

+ 2 - 0
desktop/libs/metadata/src/metadata/navigator_client_tests.py

@@ -79,3 +79,5 @@ class TestNavigatorclient:
 
     # type:table tax
     # owner:romain ca
+
+    # *