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 1B7DC431FDA for ; Tue, 11 Mar 2014 15:20:19 -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 aQuQ3lyH0dvs for ; Tue, 11 Mar 2014 15:20:15 -0700 (PDT) Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu [18.7.68.37]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 560E8431FBF for ; Tue, 11 Mar 2014 15:20:15 -0700 (PDT) X-AuditID: 12074425-f79906d000000cf9-eb-531f8c1b37d9 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) (using TLS with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id 12.8F.03321.B1C8F135; Tue, 11 Mar 2014 18:20:11 -0400 (EDT) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id s2BMK9Pm028026; Tue, 11 Mar 2014 18:20:10 -0400 Received: from drake.dyndns.org (31-33-67.wireless.csail.mit.edu [128.31.33.67]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s2BMK86j024800 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Tue, 11 Mar 2014 18:20:09 -0400 Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1WNV1r-0003Ma-Mb; Tue, 11 Mar 2014 18:20:07 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 2/2] emacs: Use whitelist instead of blacklist for term escaping Date: Tue, 11 Mar 2014 18:19:54 -0400 Message-Id: <1394576394-12816-2-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1394576394-12816-1-git-send-email-amdragon@mit.edu> References: <1394576394-12816-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRmVeSWpSXmKPExsUixG6noivdIx9sMGW7pcX1mzOZHRg9nq26 xRzAGMVlk5Kak1mWWqRvl8CV0XxDs+AET8XF+fsYGxgXc3UxcnJICJhIzFqwiB3CFpO4cG89 G4gtJDCbSeLyM/0uRi4geyOjRPujiYwQzjEmiR/zZjBDOHMZJf5+28sM0sImoCGxbf9yRhBb REBaYufd2axdjBwczAJqEn+6VEBMYYEAiSkn1EAqWARUJc7/XMoCEuYVcJA4s18d4gYliYWn trGC2JwCjhLT5k5jBikRAiqZudhuAiP/AkaGVYyyKblVurmJmTnFqcm6xcmJeXmpRboWermZ JXqpKaWbGMHB4qK6g3HCIaVDjAIcjEo8vA4K8sFCrIllxZW5hxglOZiURHlndwCF+JLyUyoz Eosz4otKc1KLDzFKcDArifB+1ATK8aYkVlalFuXDpKQ5WJTEefvOSgQLCaQnlqRmp6YWpBbB ZGU4OJQkeJd3ATUKFqWmp1akZeaUIKSZODhBhvMADWfoBhleXJCYW5yZDpE/xagoJc67EKRZ ACSRUZoH1wuL5leM4kCvCPNGgVTxABMBXPcroMFMQIN/BIANLklESEk1MGaoqXiejjzxQ/Sg tdMB7sPL3/N1Htu+ozQj4YHaQ67ebxxuuZka75+0tm2rvNXqVPGD71982Y9d7mdEim7mrbSW +7kxiNHZcdGaQsVZ6u9VM+a0lH0pfZrO+7fh09XDP4VqF7QeuOWS+K2B9Tmr387ic4UM5/NL zlv7zq2Uvcp4b0rUlDSPnUosxRmJhlrMRcWJACcPjBPBAgAA 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 22:20:19 -0000 Previously, the term escaper used a blacklist of characters that needed escaping. This blacklist turned out to be somewhat incomplete; for example, it did not contain non-whitespace ASCII control characters or Unicode "fancy quotes", both of which do require the term to be escaped. Switch to a whitelist of characters that are definitely safe to leave unquoted. This fixes the broken test introduced by the previous patch. --- emacs/notmuch-lib.el | 5 ++++- test/T310-emacs.sh | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 2fefdad..b071b2f 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -426,7 +426,10 @@ user-friendly queries." (save-match-data (if (or (equal term "") - (string-match "[ ()]\\|^\"" term)) + ;; To be pessimistic, only pass through terms composed + ;; entirely of ASCII printing characters other than ", (, + ;; and ). + (string-match "[^!#-'*-~]" term)) ;; Requires escaping (concat "\"" (replace-regexp-in-string "\"" "\"\"" term t t) "\"") term))) diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh index 6c18bbd..ac966e5 100755 --- a/test/T310-emacs.sh +++ b/test/T310-emacs.sh @@ -954,7 +954,6 @@ output=$(notmuch search --output=messages 'tag:search-global-race-tag') test_expect_equal "$output" "id:$gen_msg_id_1" test_begin_subtest "Term escaping" -test_subtest_known_broken output=$(test_emacs "(mapcar 'notmuch-escape-boolean-term (list \"\" \"abc\`~\!@#\$%^&*-=_+123\" -- 1.8.4.rc3