From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 34FDB6DE0260 for ; Sun, 30 Sep 2018 09:28:09 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.002 X-Spam-Level: X-Spam-Status: No, score=0.002 tagged_above=-999 required=5 tests=[AWL=0.013, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7YbJlqTR_czZ for ; Sun, 30 Sep 2018 09:28:07 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id D40AA6DE00C6 for ; Sun, 30 Sep 2018 09:28:06 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1g6eZh-0004Mi-5d; Sun, 30 Sep 2018 12:28:05 -0400 Received: (nullmailer pid 10907 invoked by uid 1000); Sun, 30 Sep 2018 16:28:02 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 2/2] lib: use phrase search for anything not ending in '*' Date: Sun, 30 Sep 2018 13:27:55 -0300 Message-Id: <20180930162755.10856-2-david@tethera.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180930162755.10856-1-david@tethera.net> References: <20180930162755.10856-1-david@tethera.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Sep 2018 16:28:09 -0000 Anything that does not look like a wildcard should be safe to quote. This should fix the problem searching for xapian keywords. --- lib/regexp-fields.cc | 2 +- test/T650-regexp-query.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc index 084bc8c0..52f30d82 100644 --- a/lib/regexp-fields.cc +++ b/lib/regexp-fields.cc @@ -194,7 +194,7 @@ RegexpFieldProcessor::operator() (const std::string & str) * phrase parsing, when possible */ std::string query_str; - if (str.find (' ') != std::string::npos) + if (*str.rbegin () != '*' || str.find (' ') != std::string::npos) query_str = '"' + str + '"'; else query_str = str; diff --git a/test/T650-regexp-query.sh b/test/T650-regexp-query.sh index 7448c024..181e3856 100755 --- a/test/T650-regexp-query.sh +++ b/test/T650-regexp-query.sh @@ -81,12 +81,10 @@ add_message '[from]="and"' '[subject]="and-and-and"' printf "id:$gen_msg_id\n" > EXPECTED test_begin_subtest "quoted xapian keyword search for from:" -test_subtest_known_broken notmuch search --output=messages 'from:"and"' > OUTPUT test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "quoted xapian keyword search for subject:" -test_subtest_known_broken notmuch search --output=messages 'subject:"and-and-and"' > OUTPUT test_expect_equal_file EXPECTED OUTPUT -- 2.19.0