changeset 1443:d5a240018922

handle invalid search queries
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Mon, 21 Aug 2006 13:28:49 +0200
parents ce3a2506c433
children 1a3c73509f15
files MoinMoin/action/fullsearch.py
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/fullsearch.py	Mon Aug 21 13:23:23 2006 +0200
+++ b/MoinMoin/action/fullsearch.py	Mon Aug 21 13:28:49 2006 +0200
@@ -127,9 +127,15 @@
 
     # search the pages
     from MoinMoin.search import searchPages, QueryParser
-    query = QueryParser(case=case, regex=regex,
-            titlesearch=titlesearch).parse_query(needle)
-    results = searchPages(request, query, sort, mtime, historysearch)
+    try:
+        query = QueryParser(case=case, regex=regex,
+                titlesearch=titlesearch).parse_query(needle)
+        results = searchPages(request, query, sort, mtime, historysearch)
+    except ValueError:
+        err = _('Your search query {{{"%s"}}} is invalid. Please refer to '
+                'HelpOnSearch for more information.') % needle
+        Page(request, pagename).send_page(request, msg=err)
+        return
 
     # directly show a single hit
     # XXX won't work with attachment search