]> diplodocus.org Git - nmh/commitdiff
With EAI (mhbuild -headerencoding utf-8), force message header to
authorDavid Levine <levinedl@acm.org>
Tue, 18 Oct 2016 23:55:49 +0000 (19:55 -0400)
committerDavid Levine <levinedl@acm.org>
Tue, 18 Oct 2016 23:55:49 +0000 (19:55 -0400)
show 8-bit UTF-8, even if the message body is ASCII.

test/post/test-rfc6531
uip/mhbuildsbr.c

index 8d5391dc1a558eaade8e886e2dd1e941ea0bf70a..817388dab9ea6f56c2b22267b83219718add954a 100755 (executable)
@@ -69,6 +69,39 @@ EOF
 test_post "${testname}.actual" "${testname}.expected"
 
 
 test_post "${testname}.actual" "${testname}.expected"
 
 
+# check SMTPUTF8 without 8-bit body
+start_test '8-bit headers with ASCII body'
+
+cat > "${testname}.expected" <<EOF
+EHLO nosuchhost.example.com
+MAIL FROM:<senderø@example.com> BODY=8BITMIME SMTPUTF8
+RCPT TO:<recipientæ@example.com>
+DATA
+From: senderø@example.com
+To: recipientæ@example.com
+Subject: Blåbærsyltetøy
+MIME-Version: 1.0
+Content-Type: text/plain; charset="UTF-8"
+Content-Transfer-Encoding: 8bit
+Date:
+
+This is a test.
+.
+QUIT
+EOF
+
+cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
+From: senderø@example.com
+To: recipientæ@example.com
+Subject: Blåbærsyltetøy
+--------
+This is a test.
+EOF
+
+test_post "${testname}.actual" "${testname}.expected"
+
+
+# check with smtp server that doesn't support SMTPUTF8
 start_test "smtp server doesn't support SMTPUTF8"
 unset SMTPUTF8
 cat > "${testname}.expected" <<EOF
 start_test "smtp server doesn't support SMTPUTF8"
 unset SMTPUTF8
 cat > "${testname}.expected" <<EOF
index aefa1f3e27fcc5eab2c95bcc7fb55817a1e3347a..c72bd8185a8a6ee01a0c3dc18965ba58d23d481c 100644 (file)
@@ -560,6 +560,13 @@ finish_field:
     if ((cp = strchr(prefix, 'a')) == NULL)
        adios (NULL, "internal error(4)");
 
     if ((cp = strchr(prefix, 'a')) == NULL)
        adios (NULL, "internal error(4)");
 
+    /*
+     * If using EAI, force 8-bit charset.
+     */
+    if (header_encoding == CE_8BIT) {
+        set_charset (ct, 1);
+    }
+
     /*
      * Scan the contents.  Choose a transfer encoding, and
      * check if prefix for multipart boundary clashes with
     /*
      * Scan the contents.  Choose a transfer encoding, and
      * check if prefix for multipart boundary clashes with
@@ -1779,7 +1786,12 @@ skip_headers:
 
     /*
      * output the Content-Transfer-Encoding
 
     /*
      * output the Content-Transfer-Encoding
+     * If using EAI and message body is 7-bit, force 8-bit C-T-E.
      */
      */
+    if (header_encoding == CE_8BIT  &&  ct->c_encoding == CE_7BIT) {
+        ct->c_encoding = CE_8BIT;
+    }
+
     switch (ct->c_encoding) {
     case CE_7BIT:
        /* Nothing to output */
     switch (ct->c_encoding) {
     case CE_7BIT:
        /* Nothing to output */