fusion: Allow quotes around attribute values in display names.

This commit is contained in:
Hans Leidekker 2012-05-16 10:07:35 +02:00 committed by Alexandre Julliard
parent aa2ad840b9
commit 003efbee0d
2 changed files with 66 additions and 14 deletions

View file

@ -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;

View file

@ -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 );