--- rfc2047.el~ 2004-11-23 21:49:55 +0000 +++ rfc2047.el 2005-02-14 07:13:18 +0000 @@ -35,6 +35,7 @@ (require 'qp) (require 'mm-util) +(require 'ietf-drums) ;; Fixme: Avoid this (used for mail-parse-charset) mm dependence on gnus. (require 'mail-prsvr) (require 'base64) @@ -337,13 +338,23 @@ ;; Does it need encoding? (goto-char start) (if (re-search-forward encodable-regexp end 'move) - ;; It needs encoding. Strip the quotes first, - ;; since encoded words can't occur in quotes. - (progn - (goto-char end) - (delete-backward-char 1) - (goto-char start) - (delete-char 1) + ;; It needs encoding. + (let ((tspecials (progn + (goto-char (1+ start)) + (re-search-forward + (concat "[" ietf-drums-tspecials "]") + (1- end) t)))) + (if tspecials + ;; Don't strip the quotes which should be + ;; included in the encoded word, since there + ;; are special characters. + (goto-char start) + ;; Strip the quotes first, since encoded words + ;; can't occur in quotes. + (goto-char end) + (delete-backward-char 1) + (goto-char start) + (delete-char 1)) (when last-encoded ;; There was a preceding quoted word. We need ;; to include any separating whitespace in this @@ -354,7 +365,9 @@ (setq start (point) end (1+ end))) ;; Adjust the end position for the deleted quotes. - (rfc2047-encode start (- end 2)) + (rfc2047-encode start (if tspecials + end + (- end 2))) (setq last-encoded t)) ; record that it was encoded (setq last-encoded nil))) ((eq ?. csyntax) @@ -766,8 +779,7 @@ (let* ((rfc2047-encoding-type 'mime) (rfc2047-encode-max-chars nil) (string (rfc2047-encode-string value))) - (if (string-match "[][()<>@,;:\\\"/?=]" ;; tspecials - string) + (if (string-match (concat "[" ietf-drums-tspecials "]") string) (format "%s=%S" param string) (concat param "=" string))))