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 <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Autosubmit: sterni <sternenseemann@systemli.org>
This commit is contained in:
sterni 2024-12-02 18:33:31 +01:00 committed by clbot
parent 4ef8ee6f1e
commit db2fa5b3c8

View file

@ -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)))