mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
emacs: Use whitelist instead of blacklist for term escaping
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.
This commit is contained in:
parent
716af7deb8
commit
92c3fd938e
2 changed files with 4 additions and 2 deletions
|
@ -426,7 +426,10 @@ user-friendly queries."
|
||||||
|
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(if (or (equal term "")
|
(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
|
;; Requires escaping
|
||||||
(concat "\"" (replace-regexp-in-string "\"" "\"\"" term t t) "\"")
|
(concat "\"" (replace-regexp-in-string "\"" "\"\"" term t t) "\"")
|
||||||
term)))
|
term)))
|
||||||
|
|
|
@ -954,7 +954,6 @@ output=$(notmuch search --output=messages 'tag:search-global-race-tag')
|
||||||
test_expect_equal "$output" "id:$gen_msg_id_1"
|
test_expect_equal "$output" "id:$gen_msg_id_1"
|
||||||
|
|
||||||
test_begin_subtest "Term escaping"
|
test_begin_subtest "Term escaping"
|
||||||
test_subtest_known_broken
|
|
||||||
output=$(test_emacs "(mapcar 'notmuch-escape-boolean-term (list
|
output=$(test_emacs "(mapcar 'notmuch-escape-boolean-term (list
|
||||||
\"\"
|
\"\"
|
||||||
\"abc\`~\!@#\$%^&*-=_+123\"
|
\"abc\`~\!@#\$%^&*-=_+123\"
|
||||||
|
|
Loading…
Reference in a new issue