]> diplodocus.org Git - nmh/commitdiff
Permit the matching of canonical MIME multipart boundaries
authorKen Hornstein <kenh@pobox.com>
Mon, 29 Apr 2019 01:07:24 +0000 (21:07 -0400)
committerKen Hornstein <kenh@pobox.com>
Mon, 29 Apr 2019 01:07:24 +0000 (21:07 -0400)
Allow the matching of MIME multipart boundaries if the message is
in canonical form (\r\n line endings).

uip/mhparse.c

index f0cdc68..fe18530 100644 (file)
@@ -1153,6 +1153,23 @@ InitMultiPart (CT ct)
        pos += gotlen;
        if (bufp[0] != '-' || bufp[1] != '-')
            continue;
+
+       /*
+        * A bit of a lame hack; if this line ends in \r\n then replace
+        * the \r\n with just a \n so that the boundary markers will match
+        * up properly in case this uses "MS-DOS" line endings.
+        */
+
+       if (gotlen > 2 && bufp[gotlen - 1] == '\n' &&
+           bufp[gotlen - 2] == '\r') {
+               /*
+                * Note we don't change getpos here, because it is used to
+                * calculate multipart offsets.
+                */
+               bufp[gotlen - 2] = '\n';
+               bufp[gotlen - 1] = '\0';
+       }
+
        if (inout) {
            if (strcmp (bufp + 2, m->mp_start))
                continue;