From: Austin Clements Date: Tue, 11 Mar 2014 20:42:00 +0000 (+2000) Subject: [PATCH v2] util: Fix two corner-cases in boolean term quoting function X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ad19f5e64d8bbbd423b5cb0d47ed73ef1d045fae;p=notmuch-archives.git [PATCH v2] util: Fix two corner-cases in boolean term quoting function --- diff --git a/00/b36b61f576aabc6aff05430f007fc4f85d9565 b/00/b36b61f576aabc6aff05430f007fc4f85d9565 new file mode 100644 index 000000000..417e3c5c1 --- /dev/null +++ b/00/b36b61f576aabc6aff05430f007fc4f85d9565 @@ -0,0 +1,108 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 3B97C431FBF + for ; Tue, 11 Mar 2014 13:42:23 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 66gwlciz84va for ; + Tue, 11 Mar 2014 13:42:17 -0700 (PDT) +Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu + [18.9.25.15]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id D6F7D431FBD + for ; Tue, 11 Mar 2014 13:42:16 -0700 (PDT) +X-AuditID: 1209190f-f790b6d000000c3a-58-531f752755b6 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP + id F7.E2.03130.7257F135; Tue, 11 Mar 2014 16:42:15 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s2BKgETh018335; + Tue, 11 Mar 2014 16:42:14 -0400 +Received: from drake.dyndns.org (26-4-172.dynamic.csail.mit.edu [18.26.4.172]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s2BKgCgM007336 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Tue, 11 Mar 2014 16:42:13 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1WNTUy-00065X-C2; Tue, 11 Mar 2014 16:42:04 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v2] util: Fix two corner-cases in boolean term quoting + function +Date: Tue, 11 Mar 2014 16:42:00 -0400 +Message-Id: <1394570520-23279-1-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.8.4.rc3 +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFprJIsWRmVeSWpSXmKPExsUixCmqrKteKh9sMO2jucX1mzOZHRg9nq26 + xRzAGMVlk5Kak1mWWqRvl8CVseyRfsFvzoq+c8+ZGhgfs3cxcnJICJhI7HnXwQhhi0lcuLee + rYuRi0NIYDaTxOyrD8ESQgIbGSWaT8tBJI4wSaw4vYgFwpnLKDHl1T4mkCo2AQ2JbfuXg3WI + CEhL7Lw7m7WLkYODWUBN4k+XCkhYWMBf4t/Pq2CbWQRUJZZc/8UGYvMKOEhMXdfKBHGFksTC + U9tYJzDyLmBkWMUom5JbpZubmJlTnJqsW5ycmJeXWqRropebWaKXmlK6iREcApL8Oxi/HVQ6 + xCjAwajEwztDST5YiDWxrLgy9xCjJAeTkihvbCFQiC8pP6UyI7E4I76oNCe1+BCjBAezkgjv + R02gHG9KYmVValE+TEqag0VJnLfvrESwkEB6YklqdmpqQWoRTFaGg0NJgleyBKhRsCg1PbUi + LTOnBCHNxMEJMpwHaPieYpDhxQWJucWZ6RD5U4yKUuK8KiDNAiCJjNI8uF5YjL5iFAd6RZiX + F6SKBxjfcN2vgAYzAQ3+EQA2uCQRISXVwMiwQq+9noG/xPuV4uxzkTzzA24uPcSucLuS9wD/ + EoMVTLWyO83O2rR4N4T06X01/MClVnx4c+pzi7yK3053Ztyvkby6a7XnxWL7m89uFbmI6tTe + vBxlm7bOJY3h2PWIx+GTH3zLr7qV1h+oml/ctOn4O/UFnziiPjvc4X936t/re9vCVM0nblVi + Kc5INNRiLipOBACtuOSzrAIAAA== +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Tue, 11 Mar 2014 20:42:23 -0000 + +Previously, make_boolean_term did not quote empty boolean terms or +boolean terms that started with '('. These cases are incompatible +with Xapian: empty terms cannot be omitted, and boolean terms that +start with '(' trigger an alternate term quoting syntax. + +Fix this by quoting empty terms and terms that contain '('. +--- +The previous version missed the empty term case. + + util/string-util.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/util/string-util.c b/util/string-util.c +index 9e2f728..3e7066c 100644 +--- a/util/string-util.c ++++ b/util/string-util.c +@@ -75,10 +75,12 @@ make_boolean_term (void *ctx, const char *prefix, const char *term, + int need_quoting = 0; + + /* Do we need quoting? To be paranoid, we quote anything +- * containing a quote, even though it only matters at the ++ * containing a quote or '(', even though these only matter at the + * beginning, and anything containing non-ASCII text. */ ++ if (! term[0]) ++ need_quoting = 1; + for (in = term; *in && !need_quoting; in++) +- if (is_unquoted_terminator (*in) || *in == '"' ++ if (is_unquoted_terminator (*in) || *in == '"' || *in == '(' + || (unsigned char)*in > 127) + need_quoting = 1; + +-- +1.8.4.rc3 +