Huw Davies : inetcomm: Unquote parameter values.
Alexandre Julliard
julliard at winehq.org
Tue Dec 18 13:08:16 CST 2007
Module: wine
Branch: master
Commit: 979a43e49de5b69aa08a9ed9e72c235b784a8a40
URL: http://source.winehq.org/git/wine.git/?a=commit;h=979a43e49de5b69aa08a9ed9e72c235b784a8a40
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Dec 18 15:37:21 2007 +0000
inetcomm: Unquote parameter values.
---
dlls/inetcomm/mimeole.c | 35 ++++++++++++++++++++++++++++++++++-
dlls/inetcomm/tests/mimeole.c | 27 +++++++++++++++++++++++----
2 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c
index 38dd46b..6b5c75d 100644
--- a/dlls/inetcomm/mimeole.c
+++ b/dlls/inetcomm/mimeole.c
@@ -268,6 +268,39 @@ static void unfold_header(char *header, int len)
*(start - 1) = '\0';
}
+static char *unquote_string(const char *str)
+{
+ int quoted = 0;
+ char *ret, *cp;
+
+ while(*str == ' ' || *str == '\t') str++;
+
+ if(*str == '"')
+ {
+ quoted = 1;
+ str++;
+ }
+ ret = strdupA(str);
+ for(cp = ret; *cp; cp++)
+ {
+ if(*cp == '\\')
+ memmove(cp, cp + 1, strlen(cp + 1) + 1);
+ else if(*cp == '"')
+ {
+ if(!quoted)
+ {
+ WARN("quote in unquoted string\n");
+ }
+ else
+ {
+ *cp = '\0';
+ break;
+ }
+ }
+ }
+ return ret;
+}
+
static void add_param(header_t *header, const char *p)
{
const char *key = p, *value, *cp = p;
@@ -293,7 +326,7 @@ static void add_param(header_t *header, const char *p)
param = HeapAlloc(GetProcessHeap(), 0, sizeof(*param));
param->name = name;
- param->value = strdupA(value);
+ param->value = unquote_string(value);
list_add_tail(&header->params, ¶m->entry);
}
diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c
index c36502e..f5cd619 100644
--- a/dlls/inetcomm/tests/mimeole.c
+++ b/dlls/inetcomm/tests/mimeole.c
@@ -36,7 +36,8 @@ static char msg1[] =
"MIME-Version: 1.0\r\n"
"Content-Type: multipart/mixed;\r\n"
" boundary=\"------------1.5.0.6\";\r\n"
- " stuff=\"du;nno\"\r\n"
+ " stuff=\"du;nno\";\r\n"
+ " morestuff=\"so\\\\me\\\"thing\\\"\"\r\n"
"foo: bar\r\n"
"From: Huw Davies <huw at codeweavers.com>\r\n"
"From: Me <xxx at codeweavers.com>\r\n"
@@ -90,7 +91,7 @@ static void test_CreateBody(void)
LARGE_INTEGER off;
ULARGE_INTEGER pos;
ENCODINGTYPE enc;
- ULONG count;
+ ULONG count, found_param, i;
MIMEPARAMINFO *param_info;
IMimeAllocator *alloc;
@@ -119,7 +120,7 @@ static void test_CreateBody(void)
ok(hr == S_OK, "ret %08x\n", hr);
off.QuadPart = 0;
IStream_Seek(in, off, STREAM_SEEK_CUR, &pos);
- ok(pos.u.LowPart == 328, "pos %u\n", pos.u.LowPart);
+ ok(pos.u.LowPart == 359, "pos %u\n", pos.u.LowPart);
hr = IMimeBody_IsContentType(body, "multipart", "mixed");
ok(hr == S_OK, "ret %08x\n", hr);
@@ -153,9 +154,27 @@ static void test_CreateBody(void)
hr = IMimeBody_GetParameters(body, "Content-Type", &count, ¶m_info);
ok(hr == S_OK, "ret %08x\n", hr);
todo_wine /* native adds a charset parameter */
- ok(count == 3, "got %d\n", count);
+ ok(count == 4, "got %d\n", count);
ok(param_info != NULL, "got %p\n", param_info);
+ found_param = 0;
+ for(i = 0; i < count; i++)
+ {
+ if(!strcmp(param_info[i].pszName, "morestuff"))
+ {
+ found_param++;
+ ok(!strcmp(param_info[i].pszData, "so\\me\"thing\""),
+ "got %s\n", param_info[i].pszData);
+ }
+ else if(!strcmp(param_info[i].pszName, "stuff"))
+ {
+ found_param++;
+ ok(!strcmp(param_info[i].pszData, "du;nno"),
+ "got %s\n", param_info[i].pszData);
+ }
+ }
+ ok(found_param == 2, "matched %d params\n", found_param);
+
hr = IMimeAllocator_FreeParamInfoArray(alloc, count, param_info, TRUE);
ok(hr == S_OK, "ret %08x\n", hr);
IMimeAllocator_Release(alloc);
More information about the wine-cvs
mailing list