* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2004 */
+/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2004, 2015 */
/* License: GPL */
#include "exim.h"
uschar * val = string_cat(NULL, &size, &ptr, US"=?", 2);
uschar c;
-val = string_cat(val, &size, &ptr, charset, Ustrlen(charset));
+if (charset)
+ val = string_cat(val, &size, &ptr, charset, Ustrlen(charset));
val = string_cat(val, &size, &ptr, US"?Q?", 3);
while ((c = *fname))
if (!fgets(CS header, MIME_MAX_HEADER_SIZE, f))
{
/* Hit EOF or read error. Ugh. */
- DEBUG(D_acl) debug_printf("Hit EOF ...\n");
+ DEBUG(D_acl) debug_printf("MIME: Hit EOF ...\n");
return rc;
}
if (Ustrncmp((header+2+Ustrlen(context->boundary)), "--", 2) == 0)
{
/* END boundary found */
- DEBUG(D_acl) debug_printf("End boundary found %s\n",
+ DEBUG(D_acl) debug_printf("MIME: End boundary found %s\n",
context->boundary);
return rc;
}
- DEBUG(D_acl) debug_printf("Next part with boundary %s\n",
+ DEBUG(D_acl) debug_printf("MIME: Next part with boundary %s\n",
context->boundary);
break;
}
mh < mime_header_list + mime_header_list_size;
mh++) if (strncmpic(mh->name, header, mh->namelen) == 0)
{
- uschar * header_value = NULL;
- int header_value_len = 0;
uschar * p = header + mh->namelen;
uschar * q;
for (q = p; *q != ';' && *q; q++) ;
*mh->value = string_copynlc(p, q-p);
- DEBUG(D_acl) debug_printf("found %s MIME header, value is '%s'\n",
+ DEBUG(D_acl) debug_printf("MIME: found %s header, value is '%s'\n",
mh->name, *mh->value);
if (*(p = q)) p++; /* jump past the ; */
{
mime_parameter * mp;
- DEBUG(D_acl) debug_printf(" considering paramlist '%s'\n", p);
+ DEBUG(D_acl) debug_printf("MIME: considering paramlist '%s'\n", p);
if ( !mime_filename
- && strncmpic("content-disposition:", header, 20) == 0
- && strncmpic("filename*", p, 9) == 0
+ && strncmpic(CUS"content-disposition:", header, 20) == 0
+ && strncmpic(CUS"filename*", p, 9) == 0
)
{ /* RFC 2231 filename */
uschar * q;
uschar * s = q;
/* look for a ' in the "filename" */
- while(*s != '\'' && *s) s++; /* s is ' or NUL */
+ while(*s != '\'' && *s) s++; /* s is 1st ' or NUL */
if ((size = s-q) > 0)
- {
mime_filename_charset = string_copyn(q, size);
- p = s;
- while(*p == '\'' && *p) p++; /* p is after ' */
- }
+ if (*(p = s)) p++;
+ while(*p == '\'') p++; /* p is after 2nd ' */
}
else
p = q;
+ DEBUG(D_acl) debug_printf("MIME: charset %s fname '%s'\n",
+ mime_filename_charset ? mime_filename_charset : US"<NULL>", p);
+
temp_string = rfc2231_to_2047(p, mime_filename_charset, &slen);
- temp_string = rfc2047_decode(temp_string, FALSE, NULL, 32,
+ DEBUG(D_acl) debug_printf("MIME: 2047-name %s\n", temp_string);
+
+ temp_string = rfc2047_decode(temp_string, FALSE, NULL, ' ',
NULL, &err_msg);
+ DEBUG(D_acl) debug_printf("MIME: plain-name %s\n", temp_string);
+
size = Ustrlen(temp_string);
if (size == slen)
&dummy_errstr)
: NULL;
DEBUG(D_acl) debug_printf(
- " found %s MIME parameter in %s header, value '%s'\n",
+ "MIME: found %s parameter in %s header, value '%s'\n",
mp->name, mh->name, *mp->value);
break; /* done matching param names */
if (*p) p++;
} /* param scan on line */
- if (strncmpic("content-disposition:", header, 20) == 0)
+ if (strncmpic(CUS"content-disposition:", header, 20) == 0)
{
if (decoding_failed) mime_filename = mime_fname_rfc2231;
DEBUG(D_acl) debug_printf(
- " found %s MIME parameter in %s header, value is '%s'\n",
+ "MIME: found %s parameter in %s header, value is '%s'\n",
"filename", mh->name, mime_filename);
}
}
(nested_context.boundary != NULL) &&
(Ustrncmp(mime_content_type,"multipart",9) == 0) )
{
- DEBUG(D_acl) debug_printf("Entering multipart recursion, boundary '%s'\n",
- nested_context.boundary);
+ DEBUG(D_acl)
+ debug_printf("MIME: Entering multipart recursion, boundary '%s'\n",
+ nested_context.boundary);
nested_context.context =
context && context->context == MBC_ATTACHMENT