From 778678f53751245acfe40c9059e23bf5670c5af7 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Mon, 24 Mar 2014 22:38:50 +0200 Subject: [PATCH] Re: [PATCH 2/2] emacs: Use whitelist instead of blacklist for term escaping --- 3f/94729f32cd652788af5b995716f8529a169c3a | 108 ++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 3f/94729f32cd652788af5b995716f8529a169c3a diff --git a/3f/94729f32cd652788af5b995716f8529a169c3a b/3f/94729f32cd652788af5b995716f8529a169c3a new file mode 100644 index 000000000..89c72cc1d --- /dev/null +++ b/3f/94729f32cd652788af5b995716f8529a169c3a @@ -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 1C440431FBD + for ; Mon, 24 Mar 2014 13:39:10 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 rMBLGB8lg0Uh for ; + Mon, 24 Mar 2014 13:39:02 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 78EA0431FB6 + for ; Mon, 24 Mar 2014 13:39:02 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 38E191000E5; + Mon, 24 Mar 2014 22:38:51 +0200 (EET) +From: Tomi Ollila +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH 2/2] emacs: Use whitelist instead of blacklist for term + escaping +In-Reply-To: <1394576394-12816-2-git-send-email-amdragon@mit.edu> +References: <1394576394-12816-1-git-send-email-amdragon@mit.edu> + <1394576394-12816-2-git-send-email-amdragon@mit.edu> +User-Agent: Notmuch/0.17+156~g1203750 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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: Mon, 24 Mar 2014 20:39:10 -0000 + +On Wed, Mar 12 2014, Austin Clements wrote: + +> 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. +> --- + +LGTM. + +Tomi + +> 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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2