Module: wine Branch: master Commit: 56dc24695e6ac5141030e9c820cfd379a7a3a134 URL: http://source.winehq.org/git/wine.git/?a=commit;h=56dc24695e6ac5141030e9c820...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Jan 31 11:46:39 2017 +0100
inetcomm: Read content encoding from MIME header.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/inetcomm/mimeole.c | 24 +++++++++++++++++++++++- dlls/inetcomm/tests/mimeole.c | 10 ++-------- 2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c index 91c902f..d8253d9 100644 --- a/dlls/inetcomm/mimeole.c +++ b/dlls/inetcomm/mimeole.c @@ -765,6 +765,22 @@ static void init_content_type(MimeBody *body, header_t *header) body->content_sub_type = strdupA(slash + 1); }
+static void init_content_encoding(MimeBody *body, header_t *header) +{ + const char *encoding = header->value.u.pszVal; + + if(!strcasecmp(encoding, "base64")) + body->encoding = IET_BASE64; + else if(!strcasecmp(encoding, "quoted-printable")) + body->encoding = IET_QP; + else if(!strcasecmp(encoding, "7bit")) + body->encoding = IET_7BIT; + else if(!strcasecmp(encoding, "8bit")) + body->encoding = IET_8BIT; + else + FIXME("unknown encoding %s\n", debugstr_a(encoding)); +} + static HRESULT parse_headers(MimeBody *body, IStream *stm) { char *header_buf, *cur_header_ptr; @@ -780,8 +796,14 @@ static HRESULT parse_headers(MimeBody *body, IStream *stm) read_value(header, &cur_header_ptr); list_add_tail(&body->headers, &header->entry);
- if(header->prop->id == PID_HDR_CNTTYPE) + switch(header->prop->id) { + case PID_HDR_CNTTYPE: init_content_type(body, header); + break; + case PID_HDR_CNTXFER: + init_content_encoding(body, header); + break; + } }
HeapFree(GetProcessHeap(), 0, header_buf); diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c index 16ad06c..8028ca8 100644 --- a/dlls/inetcomm/tests/mimeole.c +++ b/dlls/inetcomm/tests/mimeole.c @@ -150,7 +150,6 @@ static void test_CreateBody(void) IStream *in; LARGE_INTEGER off; ULARGE_INTEGER pos; - ENCODINGTYPE enc; ULONG count, found_param, i; MIMEPARAMINFO *param_info; IMimeAllocator *alloc; @@ -191,9 +190,7 @@ static void test_CreateBody(void) hr = IMimeBody_IsContentType(body, "text", "plain"); todo_wine ok(hr == S_OK, "ret %08x\n", hr); - hr = IMimeBody_GetCurrentEncoding(body, &enc); - ok(hr == S_OK, "ret %08x\n", hr); - ok(enc == IET_8BIT, "encoding %d\n", enc); + test_current_encoding(body, IET_8BIT);
memset(&offsets, 0xcc, sizeof(offsets)); hr = IMimeBody_GetOffsets(body, &offsets); @@ -658,7 +655,6 @@ static void test_CreateMessage(void) ok(count == 2, "got %d\n", count); if(count == 2) { - ENCODINGTYPE encoding; IMimeBody *attachment; PROPVARIANT prop;
@@ -670,9 +666,7 @@ static void test_CreateMessage(void) hr = IMimeBody_IsContentType(attachment, "multipart", NULL); ok(hr == S_FALSE, "ret %08x\n", hr);
- hr = IMimeBody_GetCurrentEncoding(attachment, &encoding); - ok(hr == S_OK, "ret %08x\n", hr); - todo_wine ok(encoding == IET_8BIT, "ret %d\n", encoding); + test_current_encoding(attachment, IET_8BIT);
prop.vt = VT_LPSTR; hr = IMimeBody_GetProp(attachment, "Content-Transfer-Encoding", 0, &prop);