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

diff --git a/00/b36b61f576aabc6aff05430f007fc4f85d9565 b/00/b36b61f576aabc6aff05430f007fc4f85d9565
new file mode 100644 (file)
index 0000000..417e3c5
--- /dev/null
@@ -0,0 +1,108 @@
+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 3B97C431FBF\r
+       for <notmuch@notmuchmail.org>; Tue, 11 Mar 2014 13:42:23 -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 66gwlciz84va for <notmuch@notmuchmail.org>;\r
+       Tue, 11 Mar 2014 13:42:17 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu\r
+       [18.9.25.15])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id D6F7D431FBD\r
+       for <notmuch@notmuchmail.org>; Tue, 11 Mar 2014 13:42:16 -0700 (PDT)\r
+X-AuditID: 1209190f-f790b6d000000c3a-58-531f752755b6\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-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id F7.E2.03130.7257F135; Tue, 11 Mar 2014 16:42:15 -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 s2BKgETh018335; \r
+       Tue, 11 Mar 2014 16:42:14 -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 s2BKgCgM007336\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Tue, 11 Mar 2014 16:42:13 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1WNTUy-00065X-C2; Tue, 11 Mar 2014 16:42:04 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] util: Fix two corner-cases in boolean term quoting\r
+ function\r
+Date: Tue, 11 Mar 2014 16:42:00 -0400\r
+Message-Id: <1394570520-23279-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.8.4.rc3\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFprJIsWRmVeSWpSXmKPExsUixCmqrKteKh9sMO2jucX1mzOZHRg9nq26\r
+       xRzAGMVlk5Kak1mWWqRvl8CVseyRfsFvzoq+c8+ZGhgfs3cxcnJICJhI7HnXwQhhi0lcuLee\r
+       rYuRi0NIYDaTxOyrD8ESQgIbGSWaT8tBJI4wSaw4vYgFwpnLKDHl1T4mkCo2AQ2JbfuXg3WI\r
+       CEhL7Lw7m7WLkYODWUBN4k+XCkhYWMBf4t/Pq2CbWQRUJZZc/8UGYvMKOEhMXdfKBHGFksTC\r
+       U9tYJzDyLmBkWMUom5JbpZubmJlTnJqsW5ycmJeXWqRropebWaKXmlK6iREcApL8Oxi/HVQ6\r
+       xCjAwajEwztDST5YiDWxrLgy9xCjJAeTkihvbCFQiC8pP6UyI7E4I76oNCe1+BCjBAezkgjv\r
+       R02gHG9KYmVValE+TEqag0VJnLfvrESwkEB6YklqdmpqQWoRTFaGg0NJgleyBKhRsCg1PbUi\r
+       LTOnBCHNxMEJMpwHaPieYpDhxQWJucWZ6RD5U4yKUuK8KiDNAiCJjNI8uF5YjL5iFAd6RZiX\r
+       F6SKBxjfcN2vgAYzAQ3+EQA2uCQRISXVwMiwQq+9noG/xPuV4uxzkTzzA24uPcSucLuS9wD/\r
+       EoMVTLWyO83O2rR4N4T06X01/MClVnx4c+pzi7yK3053Ztyvkby6a7XnxWL7m89uFbmI6tTe\r
+       vBxlm7bOJY3h2PWIx+GTH3zLr7qV1h+oml/ctOn4O/UFnziiPjvc4X936t/re9vCVM0nblVi\r
+       Kc5INNRiLipOBACtuOSzrAIAAA==\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:42:23 -0000\r
+\r
+Previously, make_boolean_term did not quote empty boolean terms or\r
+boolean terms that started with '('.  These cases are incompatible\r
+with Xapian: empty terms cannot be omitted, and boolean terms that\r
+start with '(' trigger an alternate term quoting syntax.\r
+\r
+Fix this by quoting empty terms and terms that contain '('.\r
+---\r
+The previous version missed the empty term case.\r
+\r
+ util/string-util.c | 6 ++++--\r
+ 1 file changed, 4 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/util/string-util.c b/util/string-util.c\r
+index 9e2f728..3e7066c 100644\r
+--- a/util/string-util.c\r
++++ b/util/string-util.c\r
+@@ -75,10 +75,12 @@ 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
++    if (! term[0])\r
++      need_quoting = 1;\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