Commit bbb8ca2a authored by Slava Monich's avatar Slava Monich

Merge pull request #28 from monich/non-multipart

Handle non-multipart attachments
parents 12fc2ed9 d0e7a39a
......@@ -847,7 +847,7 @@ mms_part_decode_headers(
static
gboolean
mms_decode_attachments(
mms_decode_multipart(
struct wsp_header_iter* iter,
unsigned int flags)
{
......@@ -890,6 +890,37 @@ mms_decode_attachments(
return FALSE;
}
static
gboolean
mms_decode_attachment(
struct wsp_header_iter* iter,
unsigned int flags)
{
const unsigned char* pdu = iter->pdu + iter->pos + 1;
unsigned int len = iter->max - iter->pos - 1;
unsigned int consumed, parlen;
const void *type = NULL;
if (wsp_decode_content_type(pdu, len, &type, &consumed, &parlen)) {
unsigned int total = consumed + parlen;
unsigned int off = iter->pos + 1 + total;
len -= total;
printf("Attachment:\n");
if (flags & MMS_DUMP_FLAG_VERBOSE) {
printf("Offset: %u (0x%x)\n", off, off);
printf("Length: %u (0x%x)\n", len, len);
} else {
printf("Offset: %u\n", off);
printf("Length: %u\n", len);
}
printf(" Content-Type: %s", (char*)type);
mms_value_decode_wsp_params(pdu + consumed, parlen);
mms_value_verbose_dump(iter->pdu + iter->pos, total+1, flags);
printf("\n");
return TRUE;
}
return FALSE;
}
static
int
mms_decode_data(
......@@ -924,15 +955,21 @@ mms_decode_data(
printf("MMS headers:\n");
wsp_header_iter_init(&iter, data, len, WSP_HEADER_ITER_FLAG_REJECT_CP |
WSP_HEADER_ITER_FLAG_DETECT_MMS_MULTIPART);
if (mms_message_decode_headers(&iter, " ", flags) &&
(wsp_header_iter_at_end(&iter) ||
(wsp_header_iter_is_multipart(&iter) &&
mms_decode_attachments(&iter, flags) &&
wsp_header_iter_at_end(&iter)))) {
return RET_OK;
} else {
printf("Decoding FAILED\n");
if (mms_message_decode_headers(&iter, " ", flags)) {
if (wsp_header_iter_at_end(&iter)) {
return RET_OK;
} else if (wsp_header_iter_is_content_type(&iter)) {
if (wsp_header_iter_is_multipart(&iter)) {
if (mms_decode_multipart(&iter, flags) &&
wsp_header_iter_at_end(&iter)) {
return RET_OK;
}
} else if (mms_decode_attachment(&iter, flags)) {
return RET_OK;
}
}
}
printf("Decoding FAILED\n");
return RET_ERR_DECODE;
}
......
......@@ -1347,8 +1347,9 @@ static gboolean decode_retrieve_conf(struct wsp_header_iter *iter,
if (wsp_header_iter_at_end(iter) == TRUE)
return TRUE;
/* Ignore non-multipart attachments */
if (wsp_header_iter_is_multipart(iter) == FALSE)
return FALSE;
return wsp_header_iter_is_content_type(iter);
if (mms_parse_attachments(iter, out) == FALSE)
return FALSE;
......
......@@ -51,7 +51,7 @@ test_file(
int main(int argc, char* argv[])
{
int i, ret = RET_OK;
const char* default_files[] = {
static const char* default_files[] = {
"m-acknowledge.ind",
"m-notification_1.ind",
"m-notification_2.ind",
......@@ -62,6 +62,9 @@ int main(int argc, char* argv[])
"m-retrieve_2.conf",
"m-retrieve_3.conf",
"m-retrieve_4.conf",
"m-retrieve_5.conf",
"m-retrieve_6.conf",
"m-retrieve_7.conf",
"m-notifyresp.ind",
"m-read-rec.ind",
"m-send.conf"
......
......@@ -17,7 +17,7 @@ BuildRequires: libexif-devel
BuildRequires: libjpeg-turbo-devel
BuildRequires: pkgconfig(glib-2.0) >= 2.32
BuildRequires: pkgconfig(libsoup-2.4) >= 2.38
BuildRequires: pkgconfig(libwspcodec) >= 2.1
BuildRequires: pkgconfig(libwspcodec) >= 2.2
#BuildRequires: pkgconfig(ImageMagick)
BuildRequires: pkgconfig(Qt5Gui)
......
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