]> git.notmuchmail.org Git - notmuch/commitdiff
lib: handle empty string in regexp field processors
authorDavid Bremner <david@tethera.net>
Fri, 24 Mar 2017 22:52:51 +0000 (19:52 -0300)
committerDavid Bremner <david@tethera.net>
Wed, 29 Mar 2017 23:44:32 +0000 (20:44 -0300)
The non-field processor behaviour is is convert the corresponding
queries into a search for the unprefixed terms. This yields pretty
surprising results so I decided to generate a query that would match
the terms (i.e. none with that prefix) generated for an empty header.

lib/regexp-fields.cc
test/T650-regexp-query.sh

index 9dcf973263743ea01721bf139569cafa17577943..1651677cd8638b759a9f96838237a98aa2ef5af2 100644 (file)
@@ -148,6 +148,11 @@ RegexpFieldProcessor::RegexpFieldProcessor (std::string prefix, Xapian::QueryPar
 Xapian::Query
 RegexpFieldProcessor::operator() (const std::string & str)
 {
+    if (str.size () == 0)
+       return Xapian::Query(Xapian::Query::OP_AND_NOT,
+                            Xapian::Query::MatchAll,
+                            Xapian::Query (Xapian::Query::OP_WILDCARD, term_prefix));
+
     if (str.at (0) == '/') {
        if (str.at (str.size () - 1) == '/'){
            RegexpPostingSource *postings = new RegexpPostingSource (slot, str.substr(1,str.size () - 2));
index f2ae1387eea086c9bcb1b3227a8d702b8bd81767..9599c104d452f9d8b0f331017b500751e808138f 100755 (executable)
@@ -16,7 +16,6 @@ add_message '[from]="-" [subject]="empty from"'
 add_message '[subject]="-"'
 
 test_begin_subtest "null from: search"
-test_subtest_known_broken
 notmuch search 'from:""' | notmuch_search_sanitize > OUTPUT
 cat <<EOF > EXPECTED
 thread:XXX   2001-01-05 [1/1] -; empty from (inbox unread)
@@ -24,7 +23,6 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "null subject: search"
-test_subtest_known_broken
 notmuch search 'subject:""' | notmuch_search_sanitize > OUTPUT
 cat <<EOF > EXPECTED
 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; - (inbox unread)