[PATCH 2/4] lib: handle empty string in regexp field processors

David Bremner david at tethera.net
Fri Mar 17 20:03:01 PDT 2017


The non-field processor behaviour is is convert the corresponding
queries into a search for the unprefixed terms. This yields pretty
surprising results so decided to match any message.
---
 lib/regexp-fields.cc      | 3 +++
 test/T650-regexp-query.sh | 2 --
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc
index 8e740a81..42239a66 100644
--- a/lib/regexp-fields.cc
+++ b/lib/regexp-fields.cc
@@ -148,6 +148,9 @@ RegexpFieldProcessor::RegexpFieldProcessor (std::string prefix, Xapian::QueryPar
 Xapian::Query
 RegexpFieldProcessor::operator() (const std::string & str)
 {
+    if (str.size () == 0)
+	return Xapian::Query::MatchAll;
+
     if (str.at (0) == '/') {
 	if (str.at (str.size () - 1) == '/'){
 	    RegexpPostingSource *postings = new RegexpPostingSource (slot, str.substr(1,str.size () - 2));
diff --git a/test/T650-regexp-query.sh b/test/T650-regexp-query.sh
index b1d84439..049477b4 100755
--- a/test/T650-regexp-query.sh
+++ b/test/T650-regexp-query.sh
@@ -12,12 +12,10 @@ fi
 notmuch search --output=messages from:cworth > cworth.msg-ids
 
 test_begin_subtest "empty from: search"
-test_subtest_known_broken
 notmuch search --output=messages 'from:""' and from:cworth > OUTPUT
 test_expect_equal_file cworth.msg-ids OUTPUT
 
 test_begin_subtest "empty subject: search"
-test_subtest_known_broken
 notmuch search --output=messages 'subject:""' and from:cworth > OUTPUT
 test_expect_equal_file cworth.msg-ids OUTPUT
 test_begin_subtest "regexp from search, case sensitive"
-- 
2.11.0



More information about the notmuch mailing list