diff options
author | Miles Bader <miles@gnu.org> | 2004-09-27 07:44:44 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 2004-09-27 07:44:44 +0000 |
commit | f4dd4ae8939a407d9fa989ef0abb02f56151fe66 (patch) | |
tree | c57a8c484df2ad8b0cf2dc4696a728916b2947d1 /lisp/gnus/rfc2047.el | |
parent | 6c1178b5ee323394d4f18d83b64109f1bcae109e (diff) | |
download | emacs-f4dd4ae8939a407d9fa989ef0abb02f56151fe66.tar.gz |
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Merge from gnus--rel--5.10
Patches applied:
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-34
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-35
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-36
Update from CVS
Diffstat (limited to 'lisp/gnus/rfc2047.el')
-rw-r--r-- | lisp/gnus/rfc2047.el | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/lisp/gnus/rfc2047.el b/lisp/gnus/rfc2047.el index 978bec3c361..cbb5a1fc5b0 100644 --- a/lisp/gnus/rfc2047.el +++ b/lisp/gnus/rfc2047.el @@ -126,6 +126,25 @@ quoted-printable and base64 respectively.") ;;; Functions for encoding RFC2047 messages ;;; +(defun rfc2047-qp-or-base64 () + "Return the type with which to encode the buffer. +This is either `base64' or `quoted-printable'." + (save-excursion + (let ((limit (min (point-max) (+ 2000 (point-min)))) + (n8bit 0)) + (goto-char (point-min)) + (skip-chars-forward "\x20-\x7f\r\n\t" limit) + (while (< (point) limit) + (incf n8bit) + (forward-char 1) + (skip-chars-forward "\x20-\x7f\r\n\t" limit)) + (if (or (< (* 6 n8bit) (- limit (point-min))) + ;; Don't base64, say, a short line with a single + ;; non-ASCII char when splitting parts by charset. + (= n8bit 1)) + 'quoted-printable + 'base64)))) + (defun rfc2047-narrow-to-field () "Narrow the buffer to the header on the current line." (beginning-of-line) @@ -411,7 +430,7 @@ By default, the region is treated as containing addresses (see ;; encoding, choose the one that's shorter. (save-restriction (narrow-to-region b e) - (if (eq (mm-qp-or-base64) 'base64) + (if (eq (rfc2047-qp-or-base64) 'base64) 'B 'Q)))) (start (concat @@ -720,11 +739,15 @@ decodable." ;; Be more liberal to accept buggy base64 strings. If ;; base64-decode-string accepts buggy strings, this function could ;; be aliased to identity. - (case (mod (length string) 4) - (0 string) - (1 string) ;; Error, don't pad it. - (2 (concat string "==")) - (3 (concat string "=")))) + (if (= 0 (mod (length string) 4)) + string + (when (string-match "=+$" string) + (setq string (substring string 0 (match-beginning 0)))) + (case (mod (length string) 4) + (0 string) + (1 string) ;; Error, don't pad it. + (2 (concat string "==")) + (3 (concat string "="))))) (defun rfc2047-decode (charset encoding string) "Decode STRING from the given MIME CHARSET in the given ENCODING. |