From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [192.168.2.1] (port=22431 helo=roxburghpark.hosting-cloud.net) by systemreboot.net with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1pCgH3-0013l8-1y for guile-email@systemreboot.net; Tue, 03 Jan 2023 17:50:10 +0530 X-Mailborder-Info: host=console.hosting-cloud.net, gmt_time=1672748406, scan_time=5.83s X-Mailborder-Spam-Score: 0.8 X-Mailborder-Spam-Report: URIBL_DBL_BLOCKED_OPENDNS, URIBL_ZEN_BLOCKED_OPENDNS, ALL_TRUSTED, BAYES_40, SPF_FAIL, DKIM_SIGNED, DKIM_INVALID, MB_DMARC_FAIL, Received: from cp61.hosting-cloud.net (unknown [103.119.110.239]) by smtp.hosting-cloud.net (Postfix) with ESMTPSA id D9EE27FBA3 for ; Tue, 3 Jan 2023 23:19:49 +1100 (AEDT) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.hosting-cloud.net D9EE27FBA3 Authentication-Results: console.hosting-cloud.net; dmarc=fail (p=quarantine dis=none) header.from=tailcall.au Authentication-Results: console.hosting-cloud.net; spf=fail smtp.mailfrom=whatson@tailcall.au DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.hosting-cloud.net D9EE27FBA3 Authentication-Results: smtp.hosting-cloud.net; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=tailcall.au header.i=@tailcall.au header.b="syCvkskK"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tailcall.au ; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To :From:Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=Lxm/6ZPyR3tdNGb9NxksbvvAZriF37BZ/az/7reuM+k=; b=s yCvkskKEIvZWR7k/MKlj777Cw5WkouPwtuUvHyeLc/K8uDqpH55wbmSM3z+VSZety1XkSddEuY303 /PZ2nxl2rsQ69KvuLIj4PLL+WzAFbddDYme0vXInLPzKg/FIhacqrG3mhu8AKCaxOmGTyCgAbB5Nq SZjy8Y+1AsXQoms+AGhkzyBVHrZk1T9U2vKZ3whLrz00ntJkOyp1E0Z5Q7pQu3WZuAqunvsxtptvK lq1WlqBjsNj+K73CC71AZCI9cAPRLFuLr7FPMz1Wf3BBSP0vd58/ZpemdzZMQ2R9bDfiZpHKwS6rO l9CdZ5ZkLdDKDN3yYlbqAEXjaG6JvQKbQ==; Received: from eft1854679.lnk.telstra.net ([101.187.131.186] helo=fumo.fritz.box) by cp61.hosting-cloud.net with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1pCgGl-00Fj8L-07; Tue, 03 Jan 2023 23:19:51 +1100 From: Andrew Whatson To: guile-email@systemreboot.net Cc: Andrew Whatson Subject: [PATCH] email: Support quoted-printable CR LF sequences. Date: Tue, 3 Jan 2023 22:19:42 +1000 Message-Id: <20230103121942.10497-1-whatson@tailcall.au> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AuthUser: whatson@tailcall.au List-Id: * email/quoted-printable.scm (quoted-printable-decode): Ignore "=\r\n" sequences in the input. * tests/quoted-printable.scm ("quoted-printable decoding of soft line breaks (=\\n)", "quoted-printable decoding of soft line breaks (=\\r\\n)"): New tests. --- email/quoted-printable.scm | 5 +++-- tests/quoted-printable.scm | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/email/quoted-printable.scm b/email/quoted-printable.scm index 2c5d7a7..9d71200 100644 --- a/email/quoted-printable.scm +++ b/email/quoted-printable.scm @@ -41,11 +41,12 @@ (cond ((eof-object? c) out) ((char=? c #\=) - ;; TODO: Support "\r\n" line ending (let ((c1 (read-char in))) (unless (char=? c1 #\Newline) (let ((c2 (read-char in))) - (put-u8 out (string->number (string c1 c2) 16))))) + (unless (and (char=? c1 #\Return) + (char=? c2 #\Newline)) + (put-u8 out (string->number (string c1 c2) 16)))))) (quoted-printable-decode in out)) (else (put-u8 out (char->integer c)) (quoted-printable-decode in out))))))) diff --git a/tests/quoted-printable.scm b/tests/quoted-printable.scm index bfbd985..2a1f068 100644 --- a/tests/quoted-printable.scm +++ b/tests/quoted-printable.scm @@ -67,6 +67,12 @@ abriquent pour te la vendre une =C3=A2me vulgaire.") (quoted-printable-escape-encode-char #\return) (quoted-printable-escape-encode-char #\newline))) +(test-equal "quoted-printable decoding of soft line breaks (=\\n)" + (quoted-printable-decode "=\n") #vu8()) + +(test-equal "quoted-printable decoding of soft line breaks (=\\r\\n)" + (quoted-printable-decode "=\r\n") #vu8()) + (test-assert "quoted-printable random bytevector: quoted-printable-encode and quoted-printable-decode are inverses of each other" (every (lambda (len) (let ((x (random-bytevector len))) -- 2.38.1