Hans Leidekker : fusion: Allow quotes around attribute values in display names.
Alexandre Julliard
julliard at winehq.org
Wed May 16 14:22:39 CDT 2012
Module: wine
Branch: master
Commit: 003efbee0de4c350df15a18509050a45a432e86f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=003efbee0de4c350df15a18509050a45a432e86f
Author: Hans Leidekker <hans at codeweavers.com>
Date: Wed May 16 10:07:35 2012 +0200
fusion: Allow quotes around attribute values in display names.
---
dlls/fusion/asmname.c | 52 ++++++++++++++++++++++++++++++++----------
dlls/fusion/tests/asmname.c | 28 ++++++++++++++++++++++-
2 files changed, 66 insertions(+), 14 deletions(-)
diff --git a/dlls/fusion/asmname.c b/dlls/fusion/asmname.c
index 36d794b..d108a4d 100644
--- a/dlls/fusion/asmname.c
+++ b/dlls/fusion/asmname.c
@@ -580,10 +580,32 @@ static HRESULT parse_pubkey(IAssemblyNameImpl *name, LPCWSTR pubkey)
return S_OK;
}
+static WCHAR *parse_value( const WCHAR *str, unsigned int len )
+{
+ WCHAR *ret;
+ const WCHAR *p = str;
+ BOOL quoted = FALSE;
+ unsigned int i = 0;
+
+ if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return NULL;
+ if (*p == '\"')
+ {
+ quoted = TRUE;
+ p++;
+ }
+ while (*p && *p != '\"') ret[i++] = *p++;
+ if ((quoted && *p != '\"') || (!quoted && *p == '\"'))
+ {
+ HeapFree( GetProcessHeap(), 0, ret );
+ return NULL;
+ }
+ ret[i] = 0;
+ return ret;
+}
+
static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyName)
{
- LPWSTR str, save;
- LPWSTR ptr, ptr2;
+ LPWSTR str, save, ptr, ptr2, value;
HRESULT hr = S_OK;
BOOL done = FALSE;
@@ -651,21 +673,25 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam
}
*ptr2 = '\0';
-
+ if (!(value = parse_value( ptr, ptr2 - ptr )))
+ {
+ hr = FUSION_E_INVALID_NAME;
+ goto done;
+ }
while (*str == ' ') str++;
- if (!lstrcmpW(str, version))
- hr = parse_version(name, ptr);
- else if (!lstrcmpW(str, culture))
- hr = parse_culture(name, ptr);
- else if (!lstrcmpW(str, pubkey))
- hr = parse_pubkey(name, ptr);
- else if (!lstrcmpW(str, procarch))
+ if (!lstrcmpiW(str, version))
+ hr = parse_version( name, value );
+ else if (!lstrcmpiW(str, culture))
+ hr = parse_culture( name, value );
+ else if (!lstrcmpiW(str, pubkey))
+ hr = parse_pubkey( name, value );
+ else if (!lstrcmpiW(str, procarch))
{
- name->procarch = strdupW(ptr);
- if (!name->procarch)
- hr = E_OUTOFMEMORY;
+ name->procarch = value;
+ value = NULL;
}
+ HeapFree( GetProcessHeap(), 0, value );
if (FAILED(hr))
goto done;
diff --git a/dlls/fusion/tests/asmname.c b/dlls/fusion/tests/asmname.c
index d180b9e..ac5b27b 100644
--- a/dlls/fusion/tests/asmname.c
+++ b/dlls/fusion/tests/asmname.c
@@ -891,6 +891,32 @@ static void test_CreateAssemblyNameObject(void)
ok(hr == FUSION_E_INVALID_NAME,
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(name == (IAssemblyName *)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name);
+
+ /* no spaces */
+ to_widechar(namestr, "wine,version=1.0.0.0");
+ name = (IAssemblyName *)0xdeadbeef;
+ hr = pCreateAssemblyNameObject(&name, namestr, CANOF_PARSE_DISPLAY_NAME, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(name != NULL, "Expected non-NULL name\n");
+ hi = lo = 0xdeadbeef;
+ hr = IAssemblyName_GetVersion(name, &hi, &lo);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(hi == 65536, "Expected 536, got %u\n", hi);
+ ok(lo == 0, "Expected 0, got %u\n", lo);
+ IAssemblyName_Release(name);
+
+ /* quoted values */
+ to_widechar(namestr, "wine, version=\"1.0.0.0\",culture=\"en\"");
+ name = (IAssemblyName *)0xdeadbeef;
+ hr = pCreateAssemblyNameObject(&name, namestr, CANOF_PARSE_DISPLAY_NAME, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(name != NULL, "Expected non-NULL name\n");
+ hi = lo = 0xdeadbeef;
+ hr = IAssemblyName_GetVersion(name, &hi, &lo);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(hi == 65536, "Expected 65536, got %u\n", hi);
+ ok(lo == 0, "Expected 0, got %u\n", lo);
+ IAssemblyName_Release(name);
}
static void test_IAssemblyName_IsEqual(void)
@@ -951,7 +977,7 @@ static void test_IAssemblyName_IsEqual(void)
ok( hr == S_OK, "got %08x\n", hr );
hr = IAssemblyName_IsEqual( name1, name2, ASM_CMPF_IL_ALL );
- todo_wine ok( hr == S_FALSE, "got %08x\n", hr );
+ ok( hr == S_FALSE, "got %08x\n", hr );
IAssemblyName_Release( name1 );
hr = pCreateAssemblyNameObject( &name1, wine1, CANOF_PARSE_DISPLAY_NAME, NULL );
More information about the wine-cvs
mailing list