]> diplodocus.org Git - nmh/commitdiff
Don't bypass scan_content() when expanding pseudoheaders.
authorDavid Levine <levinedl@acm.org>
Sat, 17 Jun 2017 13:32:00 +0000 (09:32 -0400)
committerDavid Levine <levinedl@acm.org>
Sat, 17 Jun 2017 13:32:00 +0000 (09:32 -0400)
expand_pseudoheader() would avoid the call to scan_content() in order
to inhibit use of quoted-printable for text content.  Removed that;
the user still has control over the use of quoted-printable via
-maxunencoded.  Though now, lines over 998 bytes long will always
be encoded.

test/repl/test-convert
uip/mhbuildsbr.c

index f2792a69e33d1e2963536f952d71705806d976a2..0cbc13140038b9e302b29a5e3b3d08fb977e79a4 100755 (executable)
@@ -74,10 +74,10 @@ mhbuild "$actual"
 check "$actual" "$expected"
 
 
-# check that text is not quoted-printable encoded
+# check that text is quoted-printable encoded due to long text line
 # This tests the setting of reply_ct->c_reqencoding and
 # (*text_plain_ct)->c_reqencoding in expand_pseudoheader().
-start_test "don't encode text as quoted-printable"
+start_test "encode text as quoted-printable due to long text line"
 cat >"$expected" <<'EOF'
 From: recipient@example.com
 To: sender@example.com
@@ -88,10 +88,12 @@ Comments: In-reply-to sender@example.com
    message dated "Thu, 11 Dec 2014 08:19:02 -0600."
 MIME-Version: 1.0
 Content-Type: text/plain; charset="US-ASCII"
+Content-Transfer-Encoding: quoted-printable
 
 sender@example.com writes:
 
-> This is a very, very, very, very, very, very, very, very, very, very, very, long line.
+> This is a very, very, very, very, very, very, very, very, very, very, ve=
+ry, long line.
 EOF
 
 cat >`mhpath new` <<'EOF'
index e209616aec4382dc084570e00196c7ec577feff7..e34dd978f7e6669479065e094b7d4db334e06396 100644 (file)
@@ -2205,7 +2205,6 @@ expand_pseudoheader (CT ct, CT *text_plain_ct, struct multipart *m,
     struct str2init *s2i;
     CT reply_ct;
     struct part *part;
-    int eightbit = 0;
     int status;
 
     type_p = getcpy (type);
@@ -2220,15 +2219,13 @@ expand_pseudoheader (CT ct, CT *text_plain_ct, struct multipart *m,
     free (type_p);
 
     if (! (convert)) {
-        /* No mhbuild-convert- entry in mhn.defaults or profile
-           for type. */
+        /* No mhbuild-convert- entry in mhn.defaults or profile for type. */
         return;
     }
     /* reply_file is used to pass the output of the convert. */
     reply_file = getcpy (m_mktemp2 (NULL, invo_name, NULL, NULL));
     convert_command =
-        concat (convert, " ", FENDNULL(argstring), " >", reply_file,
-                NULL);
+        concat (convert, " ", FENDNULL(argstring), " >", reply_file, NULL);
 
     /* Convert here . . . */
     ct->c_storeproc = mh_xstrdup(convert_command);
@@ -2251,19 +2248,6 @@ expand_pseudoheader (CT ct, CT *text_plain_ct, struct multipart *m,
         return;
     }
 
-    /* For text content only, see if it is 8-bit text. */
-    if (reply_ct->c_type == CT_TEXT) {
-        int fd;
-
-        if ((fd = open (reply_file, O_RDONLY)) == NOTOK  ||
-            scan_input (fd, &eightbit) == NOTOK) {
-            free (reply_file);
-            inform("failed to read %s, continuing...", reply_file);
-            return;
-        } 
-        (void) close (fd);
-    }
-
     /* This sets reply_ct->c_ctparams, and reply_ct->c_termproc if the
        charset can't be handled natively. */
     for (s2i = str2cts; s2i->si_key; s2i++) {
@@ -2276,45 +2260,22 @@ expand_pseudoheader (CT ct, CT *text_plain_ct, struct multipart *m,
         (*reply_ct->c_ctinitfnx)(reply_ct);
     }
 
-    if ((cp =
-         get_param (reply_ct->c_ctinfo.ci_first_pm, "charset", '?', 1))) {
+    if ((cp = get_param (reply_ct->c_ctinfo.ci_first_pm, "charset", '?', 1))) {
         /* The reply Content-Type had the charset. */
         charset = cp;
     } else {
         set_charset (reply_ct, -1);
         charset = get_param (reply_ct->c_ctinfo.ci_first_pm, "charset", '?', 1);
-        if (reply_ct->c_reqencoding == CE_UNKNOWN  &&
-            reply_ct->c_type == CT_TEXT) {
-            /* Assume that 8bit is sufficient (for text).  In other words,
-               don't allow it to be encoded as quoted printable if lines
-               are too long.  This also sidesteps the check for whether
-               it needs to be encoded as binary; instead, it relies on
-               the applicable mhbuild-convert-text directive to ensure
-               that the resultant text is not binary. */
-            reply_ct->c_reqencoding = eightbit  ?  CE_8BIT  :  CE_7BIT;
-        }
     }
 
     /* Concatenate text/plain parts. */
-    if (reply_ct->c_type == CT_TEXT  &&
-        reply_ct->c_subtype == TEXT_PLAIN) {
+    if (reply_ct->c_type == CT_TEXT  &&  reply_ct->c_subtype == TEXT_PLAIN) {
         if (! *text_plain_ct  &&  m->mp_parts  &&  m->mp_parts->mp_part  &&
             m->mp_parts->mp_part->c_type == CT_TEXT  &&
             m->mp_parts->mp_part->c_subtype == TEXT_PLAIN) {
             *text_plain_ct = m->mp_parts->mp_part;
-            /* Make sure that the charset is set in the text/plain
-               part. */
+            /* Make sure that the charset is set in the text/plain part. */
             set_charset (*text_plain_ct, -1);
-            if ((*text_plain_ct)->c_reqencoding == CE_UNKNOWN) {
-                /* Assume that 8bit is sufficient (for text).  In other words,
-                   don't allow it to be encoded as quoted printable if lines
-                   are too long.  This also sidesteps the check for whether
-                   it needs to be encoded as binary; instead, it relies on
-                   the applicable mhbuild-convert-text directive to ensure
-                   that the resultant text is not binary. */
-                (*text_plain_ct)->c_reqencoding =
-                    eightbit  ?  CE_8BIT  :  CE_7BIT;
-            }
         }
 
         if (*text_plain_ct) {