]> git.openstreetmap.org Git - osqa.git/blobdiff - forum_modules/pgfulltext/handlers.py
Fixes some problems with urlquoting on seraches.
[osqa.git] / forum_modules / pgfulltext / handlers.py
index f6decaf01275e0d9a565e0c017a83503de150637..196790bfedc964b14fe43cb22c058fb631e96056 100644 (file)
@@ -5,8 +5,9 @@ from forum.modules.decorators import decorate
 
 @decorate(QuestionManager.search, needs_origin=False)
 def question_search(self, keywords):
-    repl_re = re.compile(r"[^\'\-_\s\w]")
+    repl_re = re.compile(r"[^\'\-_\s\w]", re.UNICODE)
     tsquery = " | ".join([k for k in repl_re.sub('', keywords).split(' ') if k])
+    ilike = keywords + u"%%"
 
     return self.extra(
                     tables = ['forum_rootnode_doc'],
@@ -17,9 +18,9 @@ def question_search(self, keywords):
                     },
                     where=["""
                            "forum_rootnode_doc"."node_id" = "forum_node"."id" AND ("forum_rootnode_doc"."document" @@ to_tsquery('english', %s) OR
-                           "forum_node"."title" ILIKE '""" + keywords.replace("'",r"\'") + """%%')
+                           "forum_node"."title" ILIKE %s)
                            """],
-                    params=[tsquery],
+                    params=[tsquery, ilike],
                     select_params=[tsquery],
                     order_by=['-ranking']
                 )