You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2023/05/09 18:07:15 UTC
[allura] branch master updated: Add the r prefix to escape sequence for search fields
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new ff071b2aa Add the r prefix to escape sequence for search fields
ff071b2aa is described below
commit ff071b2aa6b34b2941a64e53fc061cf8dc3a8dfc
Author: Carlos Cruz <ca...@slashdotmedia.com>
AuthorDate: Tue May 9 18:00:13 2023 +0000
Add the r prefix to escape sequence for search fields
---
Allura/allura/lib/search.py | 2 +-
Allura/allura/tests/unit/test_solr.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 7dd375f18..b422b2cef 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -225,7 +225,7 @@ def site_admin_search(model, q, field, **kw):
# escaping spaces with '\ ' isn't sufficient for display_name_t since its stored as text_general (why??)
# and wouldn't handle foo@bar.com split on @ either
# This should work, but doesn't for unknown reasons: q = u'{!term f=%s}%s' % (field, q)
- q = q.replace(':', '\:') # Must escape the colon for IPv6 addresses
+ q = q.replace(':', r'\:') # Must escape the colon for IPv6 addresses
q = obj.translate_query(f'{field}:({q})', fields)
kw['q.op'] = 'AND' # so that all terms within the () are required
fq = ['type_s:%s' % model.type_s]
diff --git a/Allura/allura/tests/unit/test_solr.py b/Allura/allura/tests/unit/test_solr.py
index 6ea6ca628..43dccb53d 100644
--- a/Allura/allura/tests/unit/test_solr.py
+++ b/Allura/allura/tests/unit/test_solr.py
@@ -122,7 +122,7 @@ class TestSolr(unittest.TestCase):
search.reset_mock()
site_admin_search(User, '2601:404:c300:a560:598f:9336:d2bb:9e32', 'registration_ip')
search.assert_called_once_with(
- 'registration_ip:(2601\:404\:c300\:a560\:598f\:9336\:d2bb\:9e32)', fq=fq, ignore_errors=False, **{'q.op': 'AND'})
+ r'registration_ip:(2601\:404\:c300\:a560\:598f\:9336\:d2bb\:9e32)', fq=fq, ignore_errors=False, **{'q.op': 'AND'})
class TestSearchIndexable(unittest.TestCase):