about summary refs log tree commit diff
path: root/third_party/lisp
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2024-12-02T17·33+0100
committerclbot <clbot@tvl.fyi>2024-12-02T18·08+0000
commitdb2fa5b3c8fada85de8bff6be7ef1312d7b45ef1 (patch)
treee8e16ff2a6a1a5b3dfba9bc9c63d1e440635391f /third_party/lisp
parent4ef8ee6f1e43a3a1b7f9710e8a2e069fcaaa637f (diff)
fix(3p/lisp/mime4cl): also default to :7BIT when decoding r/8974
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>
Diffstat (limited to 'third_party/lisp')
-rw-r--r--third_party/lisp/mime4cl/mime.lisp12
1 files changed, 7 insertions, 5 deletions
diff --git a/third_party/lisp/mime4cl/mime.lisp b/third_party/lisp/mime4cl/mime.lisp
index b3c10d79764a..ead6108fc668 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)))