]> git.eshelyaron.com Git - emacs.git/commitdiff
Make Gnus more liberal when interpreting Face headers again
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 15 Oct 2020 06:39:00 +0000 (08:39 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 15 Oct 2020 06:39:00 +0000 (08:39 +0200)
* lisp/gnus/gnus-fun.el (gnus-convert-face-to-png): Do it.

* lisp/gnus/gnus-util.el (gnus-base64-repad): Allow not checking
anything, but just repadding.

lisp/gnus/gnus-fun.el
lisp/gnus/gnus-util.el
test/lisp/gnus/gnus-util-tests.el

index 2461fd45fd5ca524729a269530bbcd2b57ad9b87..3218649761ab1e76707dffc7a1f29a3637ef9f3b 100644 (file)
@@ -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
index 684c535f143a0f20ca06ae5f415386a856badc7c..807bd6a14af1476e8fe5807d95f15863fba9e46e 100644 (file)
@@ -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"))
index 47f0a9cf761a9685fd967c6c85770ca40f5001be..4869d162fb3024dee9b6e1b835983b7cea75fa76 100644 (file)
   (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)