diff options
author | Katsumi Yamaoka <yamaoka@jpl.org> | 2017-01-12 23:32:41 +0000 |
---|---|---|
committer | Katsumi Yamaoka <yamaoka@jpl.org> | 2017-01-12 23:32:41 +0000 |
commit | 55b52658470322a701000e88728d096a03b7c8ca (patch) | |
tree | ece903912da12ea8a4e66ebdb58baf173e9c3b63 /lisp/mail | |
parent | 70d6f2d14f87ab8fe164e1d461b7a55ed1ca3c62 (diff) | |
download | emacs-55b52658470322a701000e88728d096a03b7c8ca.tar.gz |
Remove garbage from Content-Transfer-Encoding value (bug#25420)
* lisp/mail/ietf-drums.el (ietf-drums-strip-cte): New function.
(ietf-drums-remove-garbage): New function.
(ietf-drums-remove-whitespace): Remove CR as well.
* lisp/mail/mail-parse.el (mail-header-strip-cte):
Alias to ietf-drums-strip-cte.
* lisp/gnus/gnus-art.el (article-decode-charset):
* lisp/gnus/gnus-sum.el (gnus-summary-enter-digest-group):
* lisp/gnus/mm-decode.el (mm-dissect-buffer):
* lisp/gnus/nndoc.el (nndoc-decode-content-transfer-encoding)
(nndoc-rfc822-forward-generate-article):
* lisp/mh-e/mh-mime.el (mh-decode-message-body):
Replace mail-header-strip with mail-header-strip-cte.
Diffstat (limited to 'lisp/mail')
-rw-r--r-- | lisp/mail/ietf-drums.el | 15 | ||||
-rw-r--r-- | lisp/mail/mail-parse.el | 1 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lisp/mail/ietf-drums.el b/lisp/mail/ietf-drums.el index 8c84158a51a..a3e53cfe793 100644 --- a/lisp/mail/ietf-drums.el +++ b/lisp/mail/ietf-drums.el @@ -143,7 +143,7 @@ backslash and doublequote.") (forward-sexp 1)) ((eq c ?\() (forward-sexp 1)) - ((memq c '(?\ ?\t ?\n)) + ((memq c '(?\ ?\t ?\n ?\r)) (delete-char 1)) (t (forward-char 1)))) @@ -172,6 +172,19 @@ backslash and doublequote.") "Remove comments and whitespace from STRING." (ietf-drums-remove-whitespace (ietf-drums-remove-comments string))) +(defun ietf-drums-remove-garbage (string) + "Remove some garbage from STRING." + (while (string-match "[][()<>@,;:\\\"/?=]+" string) + (setq string (concat (substring string 0 (match-beginning 0)) + (substring string (match-end 0))))) + string) + +(defun ietf-drums-strip-cte (string) + "Remove comments, whitespace and garbage from STRING. +STRING is assumed to be a string that is extracted from +the Content-Transfer-Encoding header of a mail." + (ietf-drums-remove-garbage (inline (ietf-drums-strip string)))) + (defun ietf-drums-parse-address (string) "Parse STRING and return a MAILBOX / DISPLAY-NAME pair." (with-temp-buffer diff --git a/lisp/mail/mail-parse.el b/lisp/mail/mail-parse.el index 546673db6fd..0578b98c933 100644 --- a/lisp/mail/mail-parse.el +++ b/lisp/mail/mail-parse.el @@ -49,6 +49,7 @@ (defalias 'mail-header-remove-comments 'ietf-drums-remove-comments) (defalias 'mail-header-remove-whitespace 'ietf-drums-remove-whitespace) (defalias 'mail-header-strip 'ietf-drums-strip) +(defalias 'mail-header-strip-cte 'ietf-drums-strip-cte) (defalias 'mail-header-get-comment 'ietf-drums-get-comment) (defalias 'mail-header-parse-address 'ietf-drums-parse-address) (defalias 'mail-header-parse-addresses 'ietf-drums-parse-addresses) |