aboutsummaryrefslogtreecommitdiffhomepage
path: root/emacs/notmuch-lib.el
diff options
context:
space:
mode:
authorGravatar Austin Clements <amdragon@MIT.EDU>2013-10-11 09:53:39 -0400
committerGravatar David Bremner <bremner@debian.org>2013-10-27 09:31:29 -0300
commita7964c86d12558396cda0f297ebf8dcc602bab61 (patch)
tree78ecab23c0e1c44f6b24162c9abf74788876c8a8 /emacs/notmuch-lib.el
parent45444eebe5c618d08ab168c49201bcd3cc235506 (diff)
emacs: Sanitize authors and subjects in search and show
Authors and subjects can contain embedded, encoded control characters like "\n" and "\t" that mess up display. Transform control characters into spaces everywhere we display them in search and show.
Diffstat (limited to 'emacs/notmuch-lib.el')
-rw-r--r--emacs/notmuch-lib.el6
1 files changed, 6 insertions, 0 deletions
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 58f3313d..65412821 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -243,6 +243,12 @@ depending on the value of `notmuch-poll-script'."
"[No Subject]"
subject)))
+(defun notmuch-sanitize (str)
+ "Sanitize control character in STR.
+
+This includes newlines, tabs, and other funny characters."
+ (replace-regexp-in-string "[[:cntrl:]\x7f\u2028\u2029]+" " " str))
+
(defun notmuch-escape-boolean-term (term)
"Escape a boolean term for use in a query.