[PATCH] util: Fix corner-case in boolean term quoting function
authorAustin Clements <amdragon@MIT.EDU>
Tue, 11 Mar 2014 20:03:05 +0000 (16:03 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:00:39 +0000 (10:00 -0800)
77/fc55935f99a0282584df38cc65d730e6605372 [new file with mode: 0644]

diff --git a/77/fc55935f99a0282584df38cc65d730e6605372 b/77/fc55935f99a0282584df38cc65d730e6605372
new file mode 100644 (file)
index 0000000..5b8230a
--- /dev/null
@@ -0,0 +1,100 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id D86F9431FBF\r
+       for <notmuch@notmuchmail.org>; Tue, 11 Mar 2014 13:03:24 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id poDiAt001EjV for <notmuch@notmuchmail.org>;\r
+       Tue, 11 Mar 2014 13:03:18 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-5.mit.edu (dmz-mailsec-scanner-5.mit.edu\r
+       [18.7.68.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 79E53431FBD\r
+       for <notmuch@notmuchmail.org>; Tue, 11 Mar 2014 13:03:18 -0700 (PDT)\r
+X-AuditID: 12074422-f79526d000000c47-e4-531f6c055571\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+       (using TLS with cipher AES256-SHA (256/256 bits))\r
+       (Client did not present a certificate)\r
+       by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 3E.EE.03143.50C6F135; Tue, 11 Mar 2014 16:03:18 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s2BK3FMT013140; \r
+       Tue, 11 Mar 2014 16:03:15 -0400\r
+Received: from drake.dyndns.org (26-4-172.dynamic.csail.mit.edu [18.26.4.172])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s2BK3DPw022649\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Tue, 11 Mar 2014 16:03:15 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1WNStN-0005i8-Jr; Tue, 11 Mar 2014 16:03:13 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] util: Fix corner-case in boolean term quoting function\r
+Date: Tue, 11 Mar 2014 16:03:05 -0400\r
+Message-Id: <1394568185-21913-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.8.4.rc3\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFprJIsWRmVeSWpSXmKPExsUixCmqrMuWIx9scL3a4vrNmcwOjB7PVt1i\r
+       DmCM4rJJSc3JLEst0rdL4MqYsCyn4BxHxaL+16wNjHfYuhg5OSQETCQ2NP1igbDFJC7cWw8U\r
+       5+IQEpjNJNH18QgThLORUWLZ3OlQzhEmif3bDjJDOHMZJTZcX8EE0s8moCGxbf9yRhBbREBa\r
+       Yufd2axdjBwczAJqEn+6VEDCwgLuEu8WzgRbzSKgKrGh+QIziM0r4CDxY3EH1BlKEgtPbWOd\r
+       wMi7gJFhFaNsSm6Vbm5iZk5xarJucXJiXl5qka6pXm5miV5qSukmRlAIsLso7WD8eVDpEKMA\r
+       B6MSD6+DgnywEGtiWXFl7iFGSQ4mJVHeD+lAIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8HzWB\r
+       crwpiZVVqUX5MClpDhYlcd6+sxLBQgLpiSWp2ampBalFMFkZDg4lCd6XWUCNgkWp6akVaZk5\r
+       JQhpJg5OkOE8QMMFskGGFxck5hZnpkPkTzEqSonzOoA0C4AkMkrz4HphMfqKURzoFWHeeyBV\r
+       PMD4hut+BTSYCWjwjwCwwSWJCCmpBkbOxA+dJ/5NNr42/9bUhvnJb+xWnVgUX9Vfbf/kos/T\r
+       rQvCTwpcs5vtP3npz5vNwg2MJlorvbWmPpwmpTxp4fbZQitNdRrcb2Tclv3Ud9Fw+/dKDwcT\r
+       tRkcDw5PSbZ7GTlDOCL6p8ch7ZqE0rl8IctcfF9kbw/2THxySU/9/+nuElOTw8UK7jpKLMUZ\r
+       iYZazEXFiQAoJxFgrAIAAA==\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 11 Mar 2014 20:03:25 -0000\r
+\r
+Previously, make_boolean_term did not quote boolean terms that started\r
+with '('.  This is incompatible with Xapian, since boolean terms that\r
+start with '(' trigger an alternate term quoting syntax.\r
+\r
+Fix this by quoting terms that contain '('.\r
+---\r
+ util/string-util.c | 4 ++--\r
+ 1 file changed, 2 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/util/string-util.c b/util/string-util.c\r
+index 9e2f728..fd3ceb2 100644\r
+--- a/util/string-util.c\r
++++ b/util/string-util.c\r
+@@ -75,10 +75,10 @@ make_boolean_term (void *ctx, const char *prefix, const char *term,\r
+     int need_quoting = 0;\r
\r
+     /* Do we need quoting?  To be paranoid, we quote anything\r
+-     * containing a quote, even though it only matters at the\r
++     * containing a quote or '(', even though these only matter at the\r
+      * beginning, and anything containing non-ASCII text. */\r
+     for (in = term; *in && !need_quoting; in++)\r
+-      if (is_unquoted_terminator (*in) || *in == '"'\r
++      if (is_unquoted_terminator (*in) || *in == '"' || *in == '('\r
+           || (unsigned char)*in > 127)\r
+           need_quoting = 1;\r
\r
+-- \r
+1.8.4.rc3\r
+\r