From 274768bc5cef49a8b08531a57da45e20889472c1 Mon Sep 17 00:00:00 2001 From: ShengHuo ZHU Date: Thu, 9 Nov 2000 20:24:49 +0000 Subject: [PATCH] 2000-11-09 16:20:37 ShengHuo ZHU * rfc2047.el (rfc2047-pad-base64): New function. (rfc2047-decode): Use it. --- lisp/ChangeLog | 5 +++++ lisp/rfc2047.el | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e96fe4697..69b7b0a18 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2000-11-09 16:20:37 ShengHuo ZHU + + * rfc2047.el (rfc2047-pad-base64): New function. + (rfc2047-decode): Use it. + 2000-11-09 08:53:04 ShengHuo ZHU * gnus-srvr.el (gnus-browse-foreign-server): Bind the original diff --git a/lisp/rfc2047.el b/lisp/rfc2047.el index fa18f9db2..081da418c 100644 --- a/lisp/rfc2047.el +++ b/lisp/rfc2047.el @@ -476,6 +476,17 @@ Return WORD if not." (error word)) word))) +(defun rfc2047-pad-base64 (string) + "Pad STRING to quartets." + ;; 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 "=")))) + (defun rfc2047-decode (charset encoding string) "Decode STRING that uses CHARSET with ENCODING. Valid ENCODINGs are \"B\" and \"Q\". @@ -501,7 +512,8 @@ If your Emacs implementation can't decode CHARSET, it returns nil." (mm-decode-coding-string (cond ((equal "B" encoding) - (base64-decode-string string)) + (base64-decode-string + (rfc2047-pad-base64 string))) ((equal "Q" encoding) (quoted-printable-decode-string (mm-replace-chars-in-string string ?_ ? ))) -- 2.25.1