X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=eword-decode.el;h=a8f34b5c70b78ffd78a8fb8d91ea30753f0dd014;hb=e896a4fe741e1127888fd800423dc2ac0fc4b063;hp=4f11e6b57f4a8c5121cbd25f207e85d01579e33f;hpb=7e7f84c58d5a26195f7308b23e01124042d75746;p=elisp%2Fflim.git diff --git a/eword-decode.el b/eword-decode.el index 4f11e6b..a8f34b5 100644 --- a/eword-decode.el +++ b/eword-decode.el @@ -32,7 +32,7 @@ ;;; Code: -(require 'std11-parse) +(require 'std11) (require 'mel) (require 'mime-def) @@ -129,11 +129,6 @@ however this behaviour violates RFC2047." ;;; @@ Quoted-Printable ;;; -(defconst quoted-printable-hex-chars "0123456789ABCDEF") -(defconst quoted-printable-octet-regexp - (concat "=[" quoted-printable-hex-chars - "][" quoted-printable-hex-chars "]")) - (defconst eword-Q-encoded-text-regexp (concat "\\([^=?]\\|" quoted-printable-octet-regexp "\\)+")) ;; (defconst eword-Q-encoding-and-encoded-text-regexp @@ -333,8 +328,8 @@ mime-charset, it decodes non-ASCII bit patterns as the mime-charset. Otherwise it decodes non-ASCII bit patterns as the default-mime-charset." (eword-decode-unstructured - code-conversion (std11-unfold-string string) + code-conversion must-unfold)) @@ -363,8 +358,8 @@ default-mime-charset." (eword-decode-unfold) ) (let ((str (eword-decode-unstructured - code-conversion (buffer-substring (point-min) (point-max)) + code-conversion must-unfold))) (delete-region (point-min) (point-max)) (insert str))))) @@ -457,7 +452,18 @@ If SEPARATOR is not nil, it is used as header separator." ;;; @ encoded-word decoder ;;; -(defvar eword-warning-face nil "Face used for invalid encoded-word.") +(defvar eword-decode-encoded-word-error-handler + 'eword-decode-encoded-word-default-error-handler) + +(defvar eword-warning-face nil + "Face used for invalid encoded-word.") + +(defun eword-decode-encoded-word-default-error-handler (word signal) + (and (add-text-properties 0 (length word) + (and eword-warning-face + (list 'face eword-warning-face)) + word) + word)) (defun eword-decode-encoded-word (word &optional must-unfold) "Decode WORD if it is an encoded-word. @@ -482,12 +488,8 @@ as a version of Net$cape)." (condition-case err (eword-decode-encoded-text charset encoding text must-unfold) (error - (and - (add-text-properties 0 (length word) - (and eword-warning-face - (list 'face eword-warning-face)) - word) - word))) + (funcall eword-decode-encoded-word-error-handler word err) + )) )) word)) @@ -595,7 +597,7 @@ be the result." (setq p (or p len)) (cons (cons 'comment (eword-decode-comment - (substring string 0 p) + (std11-unfold-string (substring string 0 p)) default-mime-charset)) (substring string p))) nil)))