From: Andrew Whatson <whatson@tailcall.au>
To: guile-email@systemreboot.net
Cc: Andrew Whatson <whatson@tailcall.au>
Subject: [PATCH] email: Support quoted-printable CR LF sequences.
Date: Tue, 3 Jan 2023 22:19:42 +1000 [thread overview]
Message-ID: <20230103121942.10497-1-whatson@tailcall.au> (raw)
* 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
next reply other threads:[~2023-01-03 12:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 12:19 Andrew Whatson [this message]
2023-01-03 14:21 ` Arun Isaac
2023-01-04 10:24 ` Andrew Whatson
2023-01-05 0:03 ` Arun Isaac
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230103121942.10497-1-whatson@tailcall.au \
--to=whatson@tailcall.au \
--cc=guile-email@systemreboot.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox