From 7f99eb44a5c734dba27682025f0dbdc253a7cabd Mon Sep 17 00:00:00 2001 From: sterni Date: Thu, 18 May 2023 17:53:52 +0200 Subject: test(3p/lisp/mime4cl): test decoding RFC2047 examples Change-Id: I32abb00e8cec697adb45b9a175cd753e807d33d5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8588 Reviewed-by: sterni Autosubmit: sterni Tested-by: BuildkiteCI --- third_party/lisp/mime4cl/endec.lisp | 2 +- third_party/lisp/mime4cl/package.lisp | 1 + third_party/lisp/mime4cl/test/endec.lisp | 21 ++++++++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'third_party/lisp/mime4cl') diff --git a/third_party/lisp/mime4cl/endec.lisp b/third_party/lisp/mime4cl/endec.lisp index d6f5ee5c79c4..2e282c237822 100644 --- a/third_party/lisp/mime4cl/endec.lisp +++ b/third_party/lisp/mime4cl/endec.lisp @@ -650,7 +650,7 @@ sequence, a charset string indicating the original coding." (defun decode-RFC2047 (text) "Decode TEXT into a fully decoded string. Whenever a non ASCII part is - encountered, try to decode it using babel, otherwise signal an error." + encountered, try to decode it using flexi-streams, otherwise signal an error." (flet ((decode-part (part) (etypecase part (cons (flexi-streams:octets-to-string diff --git a/third_party/lisp/mime4cl/package.lisp b/third_party/lisp/mime4cl/package.lisp index 3b457410dfd7..94b9e6b39053 100644 --- a/third_party/lisp/mime4cl/package.lisp +++ b/third_party/lisp/mime4cl/package.lisp @@ -69,6 +69,7 @@ #:encode-base64-stream #:encode-base64-sequence #:parse-RFC2047-text + #:decode-RFC2047 #:parse-RFC822-header #:read-RFC822-headers #:time-RFC822-string diff --git a/third_party/lisp/mime4cl/test/endec.lisp b/third_party/lisp/mime4cl/test/endec.lisp index 07e7abbf9e43..6b22b3f6a287 100644 --- a/third_party/lisp/mime4cl/test/endec.lisp +++ b/third_party/lisp/mime4cl/test/endec.lisp @@ -116,7 +116,26 @@ line") (deftest RFC2047.1 (parse-RFC2047-text "foo bar") ("foo bar")) -;; TODO(sterni): more RFC2047 test cases + +;; from RFC2047 section 8 +(deftest RFC2047.2 + (decode-RFC2047 "=?US-ASCII?Q?Keith_Moore?= ") + "Keith Moore ") + +;; from RFC2047 section 8 +(deftest RFC2047.3 + (decode-RFC2047 "=?ISO-8859-1?Q?Olle_J=E4rnefors?=") + "Olle Järnefors") + +;; from RFC2047 section 8 +(deftest RFC2047.4 + (decode-RFC2047 "Nathaniel Borenstein (=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=)") + "Nathaniel Borenstein (םולש ןב ילטפנ)") + +;; from RFC2047 section 8 +(deftest RFC2047.5 + (decode-RFC2047 "=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= ") + "Keld Jørn Simonsen ") (defun perftest-encoder (encoder-class &optional (megs 100)) (declare (optimize (speed 3) (debug 0) (safety 0)) -- cgit 1.4.1