emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master a38002c: Make Gnus more liberal when interpreting Face headers ag


From: Lars Ingebrigtsen
Subject: master a38002c: Make Gnus more liberal when interpreting Face headers again
Date: Thu, 15 Oct 2020 02:39:14 -0400 (EDT)

branch: master
commit a38002cecdb5092004a23efa9409abc7882dbdaa
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Make Gnus more liberal when interpreting Face headers again
    
    * 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             | 2 +-
 lisp/gnus/gnus-util.el            | 8 ++++++--
 test/lisp/gnus/gnus-util-tests.el | 2 --
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lisp/gnus/gnus-fun.el b/lisp/gnus/gnus-fun.el
index 2461fd4..3218649 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 684c535..807bd6a 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 47f0a9c..4869d16 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)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]