[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master eaf224f: Repad the Face header in Gnus
From: |
Alex Bochannek |
Subject: |
Re: master eaf224f: Repad the Face header in Gnus |
Date: |
Wed, 30 Sep 2020 23:58:41 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) |
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Alex Bochannek <alex@bochannek.com> writes:
>
>> I meant a trailing whitespace by itself will fail because it isn't
>> unfolded and then constitutes a invalid base 64 character.
>
> Ah, I see. OK; now applied the patch.
Thank you, Lars.
I went through a few years of Gnus newsgroups and other mailing lists to
see if I can find Face headers that break. I found two people who posted
invalid base 64 with embedded space characters. One case (a) was a
simple issue of improper header folding. The other case (b) is an odd
corner case where there is a single space right in a folded header field
and the proper padding assigned as well. How about something like this
to make case (a) display properly and not fail for case (b)?
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index 1cf6bb7053..6d348e290e 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -1343,6 +1343,16 @@ gnus-url-unhex-string
(setq tmp (concat tmp str))
tmp))
+(defcustom gnus-base64-repad-regexp "[A-Za-z0-9+/= ]"
+ "Regular expression defining valid base 64-encoded character strings
+for the gnus-base64-repad function, which is used for Face-headers.
+By default the space character is included even though it is invalid
+in base 64 because it does occasionally (and incorrectly) occur in
+Face-headers."
+ :type 'regexp
+ :version "28.0"
+ :group 'gnus-various)
+
(defun gnus-base64-repad (str &optional reject-newlines line-length)
"Take a base 64-encoded string and return it padded correctly.
Existing padding is ignored.
@@ -1378,7 +1388,8 @@ gnus-base64-repad
(dolist (substr splitstr)
(when (and line-length (> (length substr) line-length))
(error "Base64 string exceeds line-length"))
- (when (string-match "[^A-Za-z0-9+/=]" substr)
+ (when (not (string= ""
+ (replace-regexp-in-string gnus-base64-repad-regexp "" substr)))
(error "Invalid Base64 string")))
(let* ((str (string-join splitstr))
(len (length str)))
If this approach makes sense to you, I will refine it as I update the
tests. Thanks for your patience with this, I really appreciate it!
--
Alex.
- Re: master eaf224f: Repad the Face header in Gnus,
Alex Bochannek <=