]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Use whitelist instead of blacklist for term escaping
authorAustin Clements <amdragon@MIT.EDU>
Tue, 11 Mar 2014 22:19:54 +0000 (18:19 -0400)
committerDavid Bremner <david@tethera.net>
Tue, 25 Mar 2014 22:57:06 +0000 (19:57 -0300)
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
test/T310-emacs.sh

index fa7646fecb8bb020c2b06cea1fb5579be19c49f4..959764e33c98a0487a6d401ebfb7ebecd7881241 100644 (file)
@@ -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)))
index 6c18bbd792db3556940d36903bf610a0a968be70..ac966e525a04af8f88daabf618cf7af9ef08afd5 100755 (executable)
@@ -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\"