further rfc 2047 fixes
This commit is contained in:
parent
265c827fe1
commit
044e3ebbe6
|
@ -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>
|
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)
|
* 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>
|
2011-03-28 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
|
|
|
@ -259,45 +259,42 @@ static Octstr *decode_encoded_string_value(int ret, ParseContext *context, unsig
|
||||||
int val;
|
int val;
|
||||||
int ret2;
|
int ret2;
|
||||||
Octstr *res = NULL;
|
Octstr *res = NULL;
|
||||||
|
long charset = UTF8_MIB_VAL;
|
||||||
|
|
||||||
ret2 = (ret < 0) ? wsp_field_value(context, &val) : ret;
|
ret2 = (ret < 0) ? wsp_field_value(context, &val) : ret;
|
||||||
|
|
||||||
if (ret2 == WSP_FIELD_VALUE_DATA) { /* expect charset text. */
|
if (ret2 == WSP_FIELD_VALUE_DATA) { /* expect charset text. */
|
||||||
long charset; /* Get it and ignore it. */
|
|
||||||
Octstr *xs;
|
|
||||||
wsp_secondary_field_value(context, &charset);
|
wsp_secondary_field_value(context, &charset);
|
||||||
xs = parse_get_nul_string(context);
|
res = parse_get_nul_string(context);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
parse_skip_to_limit(context);
|
parse_skip_to_limit(context);
|
||||||
parse_pop_limit(context);
|
parse_pop_limit(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = pack_rfc2047_text(xs, charset);
|
|
||||||
octstr_destroy(xs);
|
|
||||||
} else if (ret2 != WSP_FIELD_VALUE_NUL_STRING) {
|
} 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);
|
mms_warning(0, "mms_msg", NULL, "Faulty header value for %s! [ret=%d,ret2=%d]\n", hname,ret,ret2);
|
||||||
res = octstr_imm("");
|
res = octstr_imm("");
|
||||||
} else { /* String may be RFC 2047 encoded */
|
} else { /* String may be RFC 2047 encoded */
|
||||||
int mib = UTF8_MIB_VAL;
|
int mib = UTF8_MIB_VAL;
|
||||||
Octstr *xs = parse_get_nul_string(context);
|
Octstr *xs = parse_get_nul_string(context);
|
||||||
|
|
||||||
res = parse_rfc2047_text(xs, &mib);
|
res = parse_rfc2047_text(xs, &mib);
|
||||||
octstr_destroy(xs);
|
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);
|
|
||||||
Octstr *out = NULL;
|
|
||||||
|
|
||||||
if (charset_to_utf8(res, &out, xcharset) > 0 && out) {
|
|
||||||
octstr_destroy(res);
|
|
||||||
res = out;
|
|
||||||
} else
|
|
||||||
octstr_destroy(out);
|
|
||||||
out = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 (xcharset != NULL && charset_to_utf8(res, &out, xcharset) > 0 && out) {
|
||||||
|
octstr_destroy(res);
|
||||||
|
res = out;
|
||||||
|
} else
|
||||||
|
octstr_destroy(out);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue