1
0
Fork 0

further rfc 2047 fixes

This commit is contained in:
bagyenda 2011-05-05 05:40:23 +00:00
parent 265c827fe1
commit 044e3ebbe6
2 changed files with 20 additions and 21 deletions

View File

@ -1,3 +1,5 @@
2011-05-05 P. A. Bagyenda <bagyenda@dsmagic.com>
* Further fixes for RFC 2047
2011-05-04 P. A. Bagyenda <bagyenda@dsmagic.com>
* Fixed parsing of encoded-string-value that contains RFC 2047 text (e.g. To, Cc, Bcc fields)
2011-03-28 P. A. Bagyenda <bagyenda@dsmagic.com>

View File

@ -259,22 +259,18 @@ static Octstr *decode_encoded_string_value(int ret, ParseContext *context, unsig
int val;
int ret2;
Octstr *res = NULL;
long charset = UTF8_MIB_VAL;
ret2 = (ret < 0) ? wsp_field_value(context, &val) : ret;
if (ret2 == WSP_FIELD_VALUE_DATA) { /* expect charset text. */
long charset; /* Get it and ignore it. */
Octstr *xs;
wsp_secondary_field_value(context, &charset);
xs = parse_get_nul_string(context);
res = parse_get_nul_string(context);
if (ret < 0) {
parse_skip_to_limit(context);
parse_pop_limit(context);
}
res = pack_rfc2047_text(xs, charset);
octstr_destroy(xs);
} else if (ret2 != WSP_FIELD_VALUE_NUL_STRING) {
mms_warning(0, "mms_msg", NULL, "Faulty header value for %s! [ret=%d,ret2=%d]\n", hname,ret,ret2);
res = octstr_imm("");
@ -284,20 +280,21 @@ static Octstr *decode_encoded_string_value(int ret, ParseContext *context, unsig
res = parse_rfc2047_text(xs, &mib);
octstr_destroy(xs);
charset = mib; /* Copy it over */
}
if (mib != UTF8_MIB_VAL && mib != US_ASCII_MIB_VAL) { /* Convert to UTF-8 */
const char *charset = mibenum_to_charset(mib);
Octstr *xcharset = octstr_imm(charset);
if (charset != UTF8_MIB_VAL && charset != US_ASCII_MIB_VAL) { /* Force to UTF-8 */
const char *_charset = mibenum_to_charset(charset);
Octstr *xcharset = _charset ? octstr_imm(_charset) : NULL;
Octstr *out = NULL;
if (charset_to_utf8(res, &out, xcharset) > 0 && out) {
if (xcharset != NULL && charset_to_utf8(res, &out, xcharset) > 0 && out) {
octstr_destroy(res);
res = out;
} else
octstr_destroy(out);
out = NULL;
}
}
return res;
}