summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/gnus/gnus-fun.el2
-rw-r--r--lisp/gnus/gnus-util.el8
-rw-r--r--test/lisp/gnus/gnus-util-tests.el2
3 files changed, 7 insertions, 5 deletions
diff --git a/lisp/gnus/gnus-fun.el b/lisp/gnus/gnus-fun.el
index 2461fd45fd5..3218649761a 100644
--- a/lisp/gnus/gnus-fun.el
+++ b/lisp/gnus/gnus-fun.el
@@ -205,7 +205,7 @@ different input formats."
(defun gnus-convert-face-to-png (face)
"Convert FACE (which is base64-encoded) to a PNG.
The PNG is returned as a string."
- (let ((face (gnus-base64-repad face)))
+ (let ((face (gnus-base64-repad face nil nil t)))
(mm-with-unibyte-buffer
(insert face)
(ignore-errors
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index 684c535f143..807bd6a14af 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -1343,7 +1343,7 @@ forbidden in URL encoding."
(setq tmp (concat tmp str))
tmp))
-(defun gnus-base64-repad (str &optional reject-newlines line-length)
+(defun gnus-base64-repad (str &optional reject-newlines line-length no-check)
"Take a base 64-encoded string and return it padded correctly.
Existing padding is ignored.
@@ -1353,7 +1353,9 @@ If LINE-LENGTH is set and the string (or any line in the string
if REJECT-NEWLINES is nil) is longer than that number, raise an
error. Common line length for input characters are 76 plus CRLF
(RFC 2045 MIME), 64 plus CRLF (RFC 1421 PEM), and 1000 including
-CRLF (RFC 5321 SMTP)."
+CRLF (RFC 5321 SMTP).
+
+If NOCHECK, don't check anything, but just repad."
;; RFC 4648 specifies that:
;; - three 8-bit inputs make up a 24-bit group
;; - the 24-bit group is broken up into four 6-bit values
@@ -1372,6 +1374,8 @@ CRLF (RFC 5321 SMTP)."
;; RFC 5322 section 2.2.3 consideration:
;; Because base 64-encoded strings can appear in long header fields, remove
;; folding whitespace while still observing the RFC 4648 decisions above.
+ (when no-check
+ (setq str (replace-regexp-in-string "[\n\r \t]+" "" str)));
(let ((splitstr (split-string str "[ \t]*[\r\n]+[ \t]?" t)))
(when (and reject-newlines (> (length splitstr) 1))
(error "Invalid Base64 string"))
diff --git a/test/lisp/gnus/gnus-util-tests.el b/test/lisp/gnus/gnus-util-tests.el
index 47f0a9cf761..4869d162fb3 100644
--- a/test/lisp/gnus/gnus-util-tests.el
+++ b/test/lisp/gnus/gnus-util-tests.el
@@ -133,8 +133,6 @@
(should (equal '("1" "1") (gnus-setdiff '(2 "1" 2 "1") '(2)))))
(ert-deftest gnus-base64-repad ()
- (should-error (gnus-base64-repad "" nil nil nil)
- :type 'wrong-number-of-arguments)
(should-error (gnus-base64-repad 1)
:type 'wrong-type-argument)