check "$expected" "$actual"
+# check removal of extraneous trailing semicolon from header parameter list
+cat >"$expected" <<EOF
+To: recipient@example.com
+Subject: test
+From: sender@example.com
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="us-ascii"
+
+test
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="us-ascii";
+ name="DATE"
+Content-Description: check folded headers, with and without trailing semicolon
+Content-Disposition: attachment;
+ filename="DATE"
+
+14 April 2014
+
+------- =_aaaaaaaaaa0--
+EOF
+
+cat >`mhpath new` <<EOF
+To: recipient@example.com
+Subject: test
+From: sender@example.com
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="us-ascii";
+
+test
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="us-ascii";
+ name="DATE"
+Content-Description: check folded headers, with and without trailing semicolon
+Content-Disposition: attachment;
+ filename="DATE";
+
+14 April 2014
+
+------- =_aaaaaaaaaa0--
+EOF
+run_test 'mhfixmsg last -outfile '"$actual" ''
+check "$expected" "$actual"
+
+
# check rmmproc
cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
mv "$1" "$1.backup"
extern int skip_mp_cte_check; /* flag to InitMultiPart */
extern int suppress_bogus_mp_content_warning; /* flag to InitMultiPart */
extern int bogus_mp_content; /* flag from InitMultiPart */
+/* flags to/from parse_header_attrs */
+extern int suppress_extraneous_trailing_semicolon_warning;
+extern int extraneous_trailing_semicolon;
/* mhoutsbr.c */
int output_message (CT, char *);
static int content_encoding (CT, const char **);
static int strip_crs (CT, int *);
static int convert_charsets (CT, char *, int *);
+static int fix_always (CT, int *);
static int write_content (CT, char *, char *, int, int);
static int remove_file (char *);
static void report (char *, char *, char *, char *, ...);
}
suppress_bogus_mp_content_warning = skip_mp_cte_check = 1;
+ suppress_extraneous_trailing_semicolon_warning = 1;
if (! context_find ("path"))
free (path ("./", TFOLDER));
}
reverse_alternative_parts (*ctp);
+ status = fix_always (*ctp, &message_mods);
if (status == OK && fx->fixboundary) {
status = fix_boundary (ctp, &message_mods);
}
}
+/*
+ * Fix various problems that aren't handled elsewhere. These
+ * are fixed unconditionally: there are no switches to disable
+ * them. (Currently, "problems" is just one: an extraneous
+ * semicolon at the end of a header parameter list.)
+ */
+static int
+fix_always (CT ct, int *message_mods) {
+ int status = OK;
+
+ switch (ct->c_type) {
+ case CT_MULTIPART: {
+ struct multipart *m = (struct multipart *) ct->c_ctparams;
+ struct part *part;
+
+ for (part = m->mp_parts; status == OK && part; part = part->mp_next) {
+ status = fix_always (part->mp_part, message_mods);
+ }
+ break;
+ }
+
+ case CT_MESSAGE:
+ if (ct->c_subtype == MESSAGE_EXTERNAL) {
+ struct exbody *e = (struct exbody *) ct->c_ctparams;
+
+ status = fix_always (e->eb_content, message_mods);
+ }
+ break;
+
+ default: {
+ HF hf;
+
+ for (hf = ct->c_first_hf; hf; hf = hf->next) {
+ const size_t len = strlen (hf->value);
+
+ if (hf->value[len - 1] == '\n' && hf->value[len - 2] == ';') {
+ /* Remove trailing ';' from parameter value. */
+ hf->value[len - 2] = '\n';
+ hf->value[len - 1] = '\0';
+
+ /* Also, if Content-Type parameter, remove trailing ';'
+ from ct->c_ctline. This probably isn't necessary
+ but can't hurt. */
+ if (strcasecmp (hf->name, "Content-Type") == 0 &&
+ ct->c_ctline &&
+ ct->c_ctline[strlen(ct->c_ctline) - 1] == ';') {
+ ct->c_ctline[strlen(ct->c_ctline) - 1] = '\0';
+ }
+
+ ++*message_mods;
+ if (verbosw) {
+ report (NULL, ct->c_partno, ct->c_file,
+ "remove trailing ; from %s parameter value",
+ hf->name);
+ }
+ }
+ }
+ }}
+
+ return status;
+}
+
+
static int
write_content (CT ct, char *input_filename, char *outfile, int modify_inplace,
int message_mods) {
* 1) Instruct parser not to detect invalid Content-Transfer-Encoding
* in a multipart.
* 2) Suppress the warning about bogus multipart content, and report it.
+ * 3) Suppress the warning about extraneous trailing ';' in header parameter
+ * lists, and report it.
*/
int skip_mp_cte_check;
int suppress_bogus_mp_content_warning;
int bogus_mp_content;
+int suppress_extraneous_trailing_semicolon_warning;
+int extraneous_trailing_semicolon;
/*
* Structures for TEXT messages
}
if (*cp == 0) {
- advise (NULL,
- "extraneous trailing ';' in message %s's %s: "
- "parameter list",
- filename, fieldname);
+ if (! suppress_extraneous_trailing_semicolon_warning) {
+ advise (NULL,
+ "extraneous trailing ';' in message %s's %s: "
+ "parameter list",
+ filename, fieldname);
+ }
+ extraneous_trailing_semicolon = 1;
return DONE;
}