X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/f9aee0f150e0d4bb93d1c8af5af2878423c81b04..e9ecb46532df39b4429a086ae72c3bfa29c122ef:/uip/mhparse.c diff --git a/uip/mhparse.c b/uip/mhparse.c index 5dae9fd7..0c2c17cd 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -330,7 +330,15 @@ get_content (FILE *in, char *file, int toplevel) 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: @@ -652,8 +660,7 @@ get_ctinfo (char *cp, CT ct, int magic) /* down case the content type string */ for (dp = ci->ci_type; *dp; dp++) - if (isalpha((unsigned char) *dp) && isupper ((unsigned char) *dp)) - *dp = tolower ((unsigned char) *dp); + *dp = tolower ((unsigned char) *dp); while (isspace ((unsigned char) *cp)) cp++; @@ -691,8 +698,7 @@ get_ctinfo (char *cp, CT ct, int magic) /* down case the content subtype string */ for (dp = ci->ci_subtype; *dp; dp++) - if (isalpha((unsigned char) *dp) && isupper ((unsigned char) *dp)) - *dp = tolower ((unsigned char) *dp); + *dp = tolower ((unsigned char) *dp); magic_skip: while (isspace ((unsigned char) *cp)) @@ -3291,8 +3297,7 @@ parse_header_attrs (const char *filename, const char *fieldname, /* down case the attribute name */ for (dp = cp; istoken ((unsigned char) *dp); dp++) - if (isalpha((unsigned char) *dp) && isupper ((unsigned char) *dp)) - *dp = tolower ((unsigned char) *dp); + *dp = tolower ((unsigned char) *dp); for (up = dp; isspace ((unsigned char) *dp);) dp++; @@ -4243,6 +4248,10 @@ noiconv: q = buffer; bufsize = sizeof(buffer); for (p = pm->pm_value; *p != '\0' && bufsize > 1; p++, q++, bufsize--) { + /* FIXME: !iscntrl should perhaps be isprint as that allows all + * classes bar cntrl, whereas the cntrl class can include those + * in space and blank. + * http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html */ if (isascii((unsigned char) *p) && !iscntrl((unsigned char) *p)) *q = *p; else