diff options
| author | Sam Varshavchik | 2018-07-29 09:43:38 -0400 |
|---|---|---|
| committer | Sam Varshavchik | 2018-07-29 09:43:38 -0400 |
| commit | 8110e928827657babbe047832460d768310d789d (patch) | |
| tree | f7955d5a635433207da3510408b23f0395c3838b /rfc2045 | |
| parent | 92af82b7b2e35f37421ff0724ffadf4eda06c840 (diff) | |
| download | courier-libs-8110e928827657babbe047832460d768310d789d.tar.bz2 | |
UTF8 changes.
Diffstat (limited to 'rfc2045')
| -rw-r--r-- | rfc2045/reformime.c | 50 | ||||
| -rw-r--r-- | rfc2045/rfc2045.c | 16 | ||||
| -rw-r--r-- | rfc2045/rfc2045.h | 2 |
3 files changed, 48 insertions, 20 deletions
diff --git a/rfc2045/reformime.c b/rfc2045/reformime.c index a47eabf..e293bc5 100644 --- a/rfc2045/reformime.c +++ b/rfc2045/reformime.c @@ -856,33 +856,54 @@ char **l; l[pcnt++]=last->fn; mimedigest1(pcnt, l); + free(l); + while(first) + { + last=first->next; + free(first->fn); + free(first); + first=last; + } } static void mimedigest1(int argc, char **argv) { -time_t t; -char boundarybuf[200]; -unsigned boundarycnt=0; -int i; -FILE *fp; + time_t t; + char boundarybuf[200]; + unsigned boundarycnt=0; + int i; + FILE *fp; + int *utf8; + if (argc == 0) + return; time (&t); + utf8=malloc(sizeof(int)*argc); + /* Search for a suitable boundary */ do { int l; - sprintf(boundarybuf, "reformime_%lu_%u", - (unsigned long)t, ++boundarycnt); + sprintf(boundarybuf, "reformime_%lu_%lu_%u", + (unsigned long)t, + (unsigned long)getpid(), + ++boundarycnt); l=strlen(boundarybuf); for (i=0; i<argc; i++) { - int err=0; + int err=0; + struct rfc2045 *parser=rfc2045_alloc(); + if (!parser) + { + perror(argv[i]); + exit(1); + } if ((fp=fopen(argv[i], "r")) == 0) { perror(argv[i]); @@ -891,6 +912,8 @@ FILE *fp; while (fgets(mimebuf, sizeof(mimebuf), fp)) { + rfc2045_parse(parser, mimebuf, strlen(mimebuf)); + if (mimebuf[0] != '-' || mimebuf[1] != '-') continue; @@ -901,6 +924,9 @@ FILE *fp; } } fclose(fp); + utf8[i]=parser->rfcviolation & RFC2045_ERR8BITHEADER + ? 1:0; + rfc2045_free(parser); if (err) break; } } while (i < argc); @@ -917,14 +943,16 @@ FILE *fp; exit(1); } - printf("\n--%s\nContent-Type: message/rfc822\n\n", - boundarybuf); + printf("\n--%s\nContent-Type: %s\n\n", + boundarybuf, + utf8[i] ? RFC2045_MIME_MESSAGE_GLOBAL: + RFC2045_MIME_MESSAGE_RFC822); while (fgets(mimebuf, sizeof(mimebuf), fp)) printf("%s", mimebuf); fclose(fp); } - + free(utf8); printf("\n--%s--\n", boundarybuf); } diff --git a/rfc2045/rfc2045.c b/rfc2045/rfc2045.c index 4e62e39..337ea34 100644 --- a/rfc2045/rfc2045.c +++ b/rfc2045/rfc2045.c @@ -743,8 +743,8 @@ char *p; int rfc2045_message_content_type(const char *content_type) { - return strcmp(content_type, RFC2045_MIME_MESSAGE_RFC822) == 0 || - strcmp(content_type, RFC2045_MIME_MESSAGE_GLOBAL) == 0; + return strcasecmp(content_type, RFC2045_MIME_MESSAGE_RFC822) == 0 || + strcasecmp(content_type, RFC2045_MIME_MESSAGE_GLOBAL) == 0; } /* @@ -753,18 +753,18 @@ int rfc2045_message_content_type(const char *content_type) int rfc2045_delivery_status_content_type(const char *content_type) { - return strcmp(content_type, + return strcasecmp(content_type, RFC2045_MIME_MESSAGE_DELIVERY_STATUS) == 0 || - strcmp(content_type, + strcasecmp(content_type, RFC2045_MIME_MESSAGE_GLOBAL_DELIVERY_STATUS) == 0; } int rfc2045_message_headers_content_type(const char *content_type) { - return strcmp(content_type, - RFC2045_MIME_MESSAGE_HEADERS) == 0 || - strcmp(content_type, - RFC2045_MIME_MESSAGE_GLOBAL_HEADERS) == 0; + return strcasecmp(content_type, + RFC2045_MIME_MESSAGE_HEADERS) == 0 || + strcasecmp(content_type, + RFC2045_MIME_MESSAGE_GLOBAL_HEADERS) == 0; } /* Various permutations of the above, including forcing the string to diff --git a/rfc2045/rfc2045.h b/rfc2045/rfc2045.h index 4abdf2c..4aec67b 100644 --- a/rfc2045/rfc2045.h +++ b/rfc2045/rfc2045.h @@ -29,7 +29,7 @@ extern "C" { #define RFC2045_MIME_MESSAGE_GLOBAL_DELIVERY_STATUS \ "message/global-delivery-status" -#define RFC2045_MIME_MESSAGE_HEADERS "message/rfc822-headers" +#define RFC2045_MIME_MESSAGE_HEADERS "text/rfc822-headers" #define RFC2045_MIME_MESSAGE_GLOBAL_HEADERS "message/global-headers" int rfc2045_message_content_type(const char *); |
