From: Lars Magne Ingebrigtsen Date: Wed, 19 May 2004 17:26:59 +0000 (+0000) Subject: (rfc2047-encode-region): Encode =? strings. X-Git-Url: http://cgit.sxemacs.org/?a=commitdiff_plain;h=dee3b415bd86cf0c59063b95edfa0c3f909138af;p=gnus (rfc2047-encode-region): Encode =? strings. (rfc2047-encodable-p): Say that =? needs encoding. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ef7926968..05544bb30 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2004-05-19 Lars Magne Ingebrigtsen + * rfc2047.el (rfc2047-encode-region): Encode =? strings. + (rfc2047-encodable-p): Say that =? needs encoding. + * gnus-group.el (gnus-group-select-group): Doc fix. * gnus-draft.el (gnus-draft-setup): Mark all replied as replied. diff --git a/lisp/rfc2047.el b/lisp/rfc2047.el index 872355bcd..b0ce5a16a 100644 --- a/lisp/rfc2047.el +++ b/lisp/rfc2047.el @@ -235,8 +235,10 @@ The buffer may be narrowed." (require 'message) ; for message-posting-charset (let ((charsets (mm-find-mime-charset-region (point-min) (point-max)))) - (and charsets - (not (equal charsets (list (car message-posting-charset))))))) + (goto-char (point-min)) + (or (search-forward "=?" nil t) + (and charsets + (not (equal charsets (list (car message-posting-charset)))))))) ;; Use this syntax table when parsing into regions that may need ;; encoding. Double quotes are string delimiters, backslash is @@ -284,18 +286,20 @@ Dynamically bind `rfc2047-encoding-type' to change that." ;; is relevant for instance in Subject headers with `Re:' for ;; interoperability with non-MIME clients, and we might as ;; well avoid the tail too. - (progn + (let ((encodable-regexp "[^\000-\177]\\|=\\?")) (goto-char (point-min)) ;; Does it need encoding? - (skip-chars-forward "\000-\177") + (re-search-forward encodable-regexp (point-max) 'move) (unless (eobp) (skip-chars-backward "^ \n") ; beginning of space-delimited word - (rfc2047-encode (point) (progn - (goto-char e) - (skip-chars-backward "\000-\177") - (skip-chars-forward "^ \n") - ;; end of space-delimited word - (point))))) + (rfc2047-encode + (point) + (progn + (goto-char e) + (re-search-backward encodable-regexp (point-max) 'move) + (skip-chars-forward "^ \n") + ;; end of space-delimited word + (point))))) ;; `address-mime' case -- take care of quoted words, comments. (with-syntax-table rfc2047-syntax-table (let ((start) ; start of current token @@ -385,7 +389,7 @@ By default, the string is treated as containing addresses (see "Encode the word(s) in the region B to E. By default, the region is treated as containing addresses (see `rfc2047-encoding-type')." - (let* ((mime-charset (mm-find-mime-charset-region b e)) + (let* ((mime-charset (or (mm-find-mime-charset-region b e) (list 'us-ascii))) (cs (if (> (length mime-charset) 1) ;; Fixme: Instead of this, try to break region into ;; parts that can be encoded separately.