]> diplodocus.org Git - nmh/commitdiff
Fixed source charset in mhfixmsg textcharset verbose output.
authorDavid Levine <levinedl@acm.org>
Wed, 25 Dec 2019 23:15:06 +0000 (18:15 -0500)
committerDavid Levine <levinedl@acm.org>
Wed, 25 Dec 2019 23:15:06 +0000 (18:15 -0500)
Thanks to Conrad Hughes for reporting this bug.

docs/pending-release-notes
test/mhfixmsg/test-mhfixmsg
uip/mhfixmsg.c

index 2c2b560..7c2e522 100644 (file)
@@ -54,3 +54,4 @@ BUG FIXES
   (or zero) attendees match a user's mailbox.
 - Fixed inc(1) and %(me) function escape to not obey Local-Mailbox profile
   component.
+- Fixed source charset in mhfixmsg textcharset verbose output.
index 66e45a3..c80cfb8 100755 (executable)
@@ -866,13 +866,32 @@ EOF
 
 if test "$ICONV_ENABLED" -eq 1; then
   run_prog mhfixmsg last -textcharset utf-8 -outfile "$actual" 2>&1
-  check "$expected" "$actual"
+  check "$expected" "$actual" 'keep first'
 else
   echo "$0: skipping -textcharset check because nmh was built without iconv"
   rm -f "$expected"
 fi
 
 
+# check -textcharset -verbose
+start_test "-textcharset -verbose"
+cat >"$expected.err" <<EOF
+mhfixmsg: 17 part 1, decode text/plain; charset="iso-8859-1"; name="square.txt"
+mhfixmsg: 17 part 1, convert iso-8859-1 to utf-8
+EOF
+
+if test "$ICONV_ENABLED" -eq 1; then
+  run_prog mhfixmsg last -textcharset utf-8 -outfile "$actual" -verbose \
+           2>"$actual.err"
+  check "$expected" "$actual"
+  check "$expected.err" "$actual.err"
+else
+    echo "$0: skipping -textcharset -verbose check because nmh was built " \
+         "without iconv"
+  rm -f "$expected" "$expected.err"
+fi
+
+
 # check -nofixboundary
 start_test "-nofixboundary"
 cat >"$expected" <<EOF
index 0cf8fe6..425801d 100644 (file)
@@ -2740,22 +2740,19 @@ convert_charsets (CT ct, char *dest_charset, int *message_mods)
     switch (ct->c_type) {
     case CT_TEXT:
         if (ct->c_subtype == TEXT_PLAIN) {
+            char *const ct_charset = content_charset (ct);
+
             status = convert_charset (ct, dest_charset, message_mods);
             if (status == OK) {
                 if (verbosw) {
-                    char *ct_charset = content_charset (ct);
-
                     report (NULL, ct->c_partno, ct->c_file,
                             "convert %s to %s", ct_charset, dest_charset);
-                    free (ct_charset);
                 }
             } else {
-                char *ct_charset = content_charset (ct);
-
                 report ("iconv", ct->c_partno, ct->c_file,
                         "failed to convert %s to %s", ct_charset, dest_charset);
-                free (ct_charset);
             }
+            free (ct_charset);
         }
         break;