Commit ae314ccc authored by Slava Monich's avatar Slava Monich

[mms_codec] Ignore incorrectly encoded subject

Subject is an optional field, it's ok if we can't decode it.
parent 18f2e972
......@@ -559,7 +559,7 @@ static gboolean extract_encoded_text(struct wsp_header_iter *iter, void *user)
const unsigned char *p;
unsigned int l;
const char *text;
char *uninitialized_var(dec_text);
char *dec_text;
p = wsp_header_iter_get_val(iter);
l = wsp_header_iter_get_val_len(iter);
......@@ -574,6 +574,7 @@ static gboolean extract_encoded_text(struct wsp_header_iter *iter, void *user)
/* (Value-len) Char-set Text-string */
dec_text = decode_encoded_string_with_mib_enum(p, l);
break;
default:
case WSP_VALUE_TYPE_SHORT:
dec_text = NULL;
break;
......@@ -587,6 +588,13 @@ static gboolean extract_encoded_text(struct wsp_header_iter *iter, void *user)
return TRUE;
}
static gboolean extract_subject(struct wsp_header_iter *iter, void *user)
{
/* Ignore incorrectly encoded subjects */
extract_encoded_text(iter, user);
return TRUE;
}
static gboolean extract_date(struct wsp_header_iter *iter, void *user)
{
time_t *out = user;
......@@ -949,7 +957,7 @@ static header_handler handler_for_type(enum mms_header header)
case MMS_HEADER_STATUS:
return &extract_status;
case MMS_HEADER_SUBJECT:
return &extract_encoded_text;
return &extract_subject;
case MMS_HEADER_TO:
return &extract_text_array_element;
case MMS_HEADER_TRANSACTION_ID:
......
......@@ -92,6 +92,11 @@ static const TestPartDesc retrieve_success3_parts [] = {
{ "text/plain;charset=utf-8", "<2>", "text_001.txt" }
};
static const TestPartDesc retrieve_invalid_subject [] = {
{ "application/smil;charset=us-ascii", "<start>", "smil.smi" },
{ "image/jpeg", "<1>", "1" }
};
#define TEST_PARTS(parts) parts, G_N_ELEMENTS(parts)
#define TEST_PARTS_NONE NULL, 0
......@@ -132,6 +137,18 @@ static const TestDesc retrieve_tests[] = {
MMS_MESSAGE_TYPE_ACKNOWLEDGE_IND,
TEST_PARTS(retrieve_success3_parts),
0
},{
"InvalidSubject",
NULL,
"m-notification.ind",
"m-retrieve.conf",
SOUP_STATUS_OK,
MMS_CONTENT_TYPE,
NULL,
MMS_RECEIVE_STATE_DECODING,
MMS_MESSAGE_TYPE_ACKNOWLEDGE_IND,
TEST_PARTS(retrieve_invalid_subject),
0
},{
"DeferSuccess",
"Success1",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment