summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorArun Isaac2019-09-23 10:35:29 +0530
committerArun Isaac2019-09-23 10:35:29 +0530
commitc10524726e0a91445a0329cc9aa72b7467258381 (patch)
tree051b5da76efe4500a25736e88863f81715144780 /tests
parent812933d29e57b2482781152933a963a1650fd548 (diff)
downloadguile-email-c10524726e0a91445a0329cc9aa72b7467258381.tar.gz
guile-email-c10524726e0a91445a0329cc9aa72b7467258381.tar.lz
guile-email-c10524726e0a91445a0329cc9aa72b7467258381.zip
email: Tolerate non-ASCII non-UTF-8 characters in headers.
* email/email.scm (email->headers+body): If non-ASCII non-UTF-8
characters occur in the headers, do not raise a decoding error. Work
around using the substitute conversion strategy.
* tests/email.scm ("tolerate non-ASCII characters in headers"): Rename
to "decode utf-8 characters in headers".
("tolerate non-ascii non-utf-8 characters in headers"): New test.

Reported-by: Christopher Baines <mail@cbaines.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/email.scm17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/email.scm b/tests/email.scm
index 8aa9082..1346b20 100644
--- a/tests/email.scm
+++ b/tests/email.scm
@@ -282,7 +282,7 @@ foo
 foo
 " "utf-8")))
 
-(test-equal "tolerate non-ascii characters in headers"
+(test-equal "decode utf-8 characters in headers"
   (parse-email
    (string->bytevector
     "From: foo@bar.org (Foo Bãr)
@@ -297,6 +297,21 @@ body" "utf-8"))
             (address . "foo@bar.org"))))
    "body"))
 
+(test-equal "tolerate non-ascii non-utf-8 characters in headers"
+  (parse-email
+   (string->bytevector
+    "From: foo@bar.org (Foo Bãr)
+
+body" "iso-8859-1"))
+  (make-email
+   `((content-type (type . text)
+                   (subtype . plain)
+                   (charset . "utf-8"))
+     (content-transfer-encoding . 7bit)
+     (from ((name . "Foo B�r")
+            (address . "foo@bar.org"))))
+   "body"))
+
 (test-equal "parse name-addr email address"
   (parse-email-address "Foo <foo@example.org>")
   '((name . "Foo") (address . "foo@example.org")))