allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject [allura] 10/13: [#7878] MockSOLR: handle unicode better
Date Fri, 24 Jan 2020 18:59:03 GMT
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit ebda6bc1c47c30e0b73b49e3d50013948a8c7358
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
AuthorDate: Fri Jan 17 16:41:25 2020 +0000

    [#7878] MockSOLR: handle unicode better
---
 Allura/allura/lib/solr.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/Allura/allura/lib/solr.py b/Allura/allura/lib/solr.py
index 307a4ab..5ad5979 100644
--- a/Allura/allura/lib/solr.py
+++ b/Allura/allura/lib/solr.py
@@ -152,11 +152,17 @@ class MockSOLR(object):
     def search(self, q, fq=None, **kw):
         if q is None:
             q = ''  # shlex will hang on None
-        if isinstance(q, six.text_type):
-            q = q.encode('latin-1')
         # Parse query
         preds = []
-        q_parts = shlex.split(q)
+        if six.PY2:
+            # shlex can't handle unicode in py2
+            q_parts = [
+                _.decode('latin-1')
+                for _ in
+                shlex.split(q.encode('latin-1'))
+            ]
+        else:
+            q_parts = shlex.split(q)
         if fq:
             q_parts += fq
         for part in q_parts:


Mime
View raw message