guile-email discussion
 help / color / mirror / Atom feed
* [PATCH] email: Support quoted-printable CR LF sequences.
@ 2023-01-03 12:19 Andrew Whatson
  2023-01-03 14:21 ` Arun Isaac
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Whatson @ 2023-01-03 12:19 UTC (permalink / raw)
  To: guile-email; +Cc: Andrew Whatson

* 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




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-05  0:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-03 12:19 [PATCH] email: Support quoted-printable CR LF sequences Andrew Whatson
2023-01-03 14:21 ` Arun Isaac
2023-01-04 10:24   ` Andrew Whatson
2023-01-05  0:03     ` Arun Isaac

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox