]> diplodocus.org Git - nmh/commitdiff
Fixed MIME parser so it can read binary content.
authorDavid Levine <levinedl@acm.org>
Fri, 21 Oct 2016 17:26:43 +0000 (13:26 -0400)
committerDavid Levine <levinedl@acm.org>
Fri, 21 Oct 2016 17:26:43 +0000 (13:26 -0400)
Second of two-part fix.  Replaced use of strlen().

Makefile.am
test/mhshow/test-binary
uip/mhparse.c

index 54d87c1..fc1bceb 100644 (file)
@@ -113,7 +113,6 @@ TESTS = test/ali/test-ali test/anno/test-anno \
        test/cleanup ## The "cleanup" test should always be last.
 
 XFAIL_TESTS = \
        test/cleanup ## The "cleanup" test should always be last.
 
 XFAIL_TESTS = \
-    test/mhshow/test-binary \
     test/scan/test-header-parsing \
     #
 
     test/scan/test-header-parsing \
     #
 
index e7407a8..95a30c7 100755 (executable)
@@ -27,7 +27,7 @@ Subject: test binary content
 
 MIME-Version: 1.0
 
 
 MIME-Version: 1.0
 
-[ part  - text/plain -   20B  ]
+[ part  - text/plain -   23B  ]
 Here's a null byte: " ".
 "
 
 Here's a null byte: " ".
 "
 
index 5dae9fd..c380969 100644 (file)
@@ -330,7 +330,15 @@ get_content (FILE *in, char *file, int toplevel)
            continue;
 
        case BODY:
            continue;
 
        case BODY:
-           ct->c_begin = ftell (in) - strlen (buf);
+           if (name[0] == ':') {
+               /* Special case:  no blank line between header and body.  The
+                  file position indicator is on the newline at the end of the
+                  line, but it needs to be one prior to the beginning of the
+                  line.  So subtract the length of the line, bufsz, plus 1. */
+               ct->c_begin = ftell (in) - (bufsz + 1);
+           } else {
+               ct->c_begin = ftell (in) - (bufsz - 1);
+           }
            break;
 
        case FILEEOF:
            break;
 
        case FILEEOF: