xapian: search: Sanitize date ranges in query string.
authorRicardo Wurmus <rekado@elephly.net>
Wed, 22 Apr 2020 13:01:58 +0000 (15:01 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Wed, 22 Apr 2020 13:01:58 +0000 (15:01 +0200)
mumi/xapian.scm

index b00e8ee75380093a84a1045bef01aa6eeb92154e..9630274847c03ce4aa30c2fa72b84318bbad835a 100644 (file)
@@ -205,9 +205,16 @@ messages and index their contents in the Xapian database at DBPATH."
   ;; closes the database once we're done.
   (call-with-database dbpath
     (lambda (db)
-      (let (;; Parse querystring passing a stemmer and suitable
+      (let* ((querystring*
+              (string-join (map (lambda (token)
+                                  (if (or (string-prefix? "date:" token)
+                                          (string-prefix? "mdate:" token))
+                                      (sanitize-date-range token)
+                                      token))
+                                (string-tokenize querystring))))
+             ;; Parse querystring passing a stemmer and suitable
             ;; prefixes for field search.
-            (query (parse-query* querystring
+            (query (parse-query* querystring*
                                  #:stemmer (make-stem "en")
                                  #:prefixes '(("submitter" . "A")
                                               ("author" . "XA")