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 2020/01/21 16:03:32 UTC

[allura] 10/12: [#7878] MockSOLR: handle unicode better

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 <db...@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: