From 265c827fe1f7c753ee23295d9a434e8efa8b51e3 Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Wed, 4 May 2011 11:19:45 +0000 Subject: [PATCH] Fixed parsing of plain RFC 2047 strings --- mbuni/ChangeLog | 2 ++ mbuni/mmlib/mms_msg.c | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/mbuni/ChangeLog b/mbuni/ChangeLog index 6009f6e..43ff4d3 100644 --- a/mbuni/ChangeLog +++ b/mbuni/ChangeLog @@ -1,3 +1,5 @@ +2011-05-04 P. A. Bagyenda + * Fixed parsing of encoded-string-value that contains RFC 2047 text (e.g. To, Cc, Bcc fields) 2011-03-28 P. A. Bagyenda * Updated doc to include mmsbox admin interface info 2011-03-24 P. A. Bagyenda diff --git a/mbuni/mmlib/mms_msg.c b/mbuni/mmlib/mms_msg.c index 3247437..d339170 100644 --- a/mbuni/mmlib/mms_msg.c +++ b/mbuni/mmlib/mms_msg.c @@ -278,9 +278,26 @@ static Octstr *decode_encoded_string_value(int ret, ParseContext *context, unsig } 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(""); - } else - res = parse_get_nul_string(context); - + } else { /* String may be RFC 2047 encoded */ + int mib = UTF8_MIB_VAL; + Octstr *xs = parse_get_nul_string(context); + + res = parse_rfc2047_text(xs, &mib); + octstr_destroy(xs); + + 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; + } + } return res; } @@ -701,7 +718,7 @@ static void mms_pack_well_known_field(Octstr *os, int field_type, Octstr *value) int charset; Octstr *xvalue = parse_rfc2047_text(value, &charset); - if (charset == US_ASCII_MIB_VAL) + if (charset == US_ASCII_MIB_VAL) /* Leave as text */ wsp_pack_text(os, xvalue); else { /* Need to use the other encoding */ wsp_pack_integer_value(encoded, charset);