allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 10/12: [#7878] MockSOLR: handle unicode better
Date Tue, 21 Jan 2020 16:03:32 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/7878
in repository https://gitbox.apache.org/repos/asf/allura.git

commit e9747460463bdbe5a5db49f2fabfd731158a593e
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