From db2fa5b3c8fada85de8bff6be7ef1312d7b45ef1 Mon Sep 17 00:00:00 2001 From: sterni Date: Mon, 2 Dec 2024 18:33:31 +0100 Subject: [PATCH] fix(3p/lisp/mime4cl): also default to :7BIT when decoding Content-Transfer-Encoding should default to 7bit when it's not given (RFC2045). MIME-PART already defaults to this when manually constructing this, but MAKE-MIME-PART would always set it, so it would sometimes be NIL which is incorrect. We now correctly fall back to :7bit in this case. Additionally, we make sure that KEYWORDIFY-ENCODING immediately returns when it's given NIL. Change-Id: I50f86dd649d83a4c3a8881d6e13dcada889d5521 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12857 Reviewed-by: sterni Tested-by: BuildkiteCI Autosubmit: sterni --- third_party/lisp/mime4cl/mime.lisp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/third_party/lisp/mime4cl/mime.lisp b/third_party/lisp/mime4cl/mime.lisp index b3c10d797..ead6108fc 100644 --- a/third_party/lisp/mime4cl/mime.lisp +++ b/third_party/lisp/mime4cl/mime.lisp @@ -677,9 +677,10 @@ body." (defun keywordify-encoding (string) "Return a keyword for a content transfer encoding string. Return STRING itself if STRING is an unkown encoding." - (aif (member string +known-encodings+ :test #'string-equal) - (car it) - string)) + (when string + (aif (member string +known-encodings+ :test #'string-equal) + (car it) + string))) (defun header (name headers) (let ((elt (assoc name headers :test #'string-equal))) @@ -714,8 +715,9 @@ guessed from the headers, use the *DEFAULT-TYPE*." :disposition (car disp) :disposition-parameters (cdr disp) :mime-version (hdr :mime-version) - :encoding (keywordify-encoding - (hdr :content-transfer-encoding)) + :encoding (or (keywordify-encoding + (hdr :content-transfer-encoding)) + :7bit) ; default per RFC2045 :description (hdr :content-description) :id (hdr :content-id) :allow-other-keys t)))