propsys: Fix comma processing in PSPropertyKeyFromString.

This commit is contained in:
Andrew Nguyen 2010-07-27 02:36:50 -05:00 committed by Alexandre Julliard
parent 067168b67b
commit 4c7f9efd16
2 changed files with 89 additions and 18 deletions

View File

@ -216,7 +216,7 @@ static BOOL string_to_guid(LPCWSTR s, LPGUID id)
HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey) HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
{ {
int has_minus = 0; int has_minus = 0, has_comma = 0;
TRACE("(%s, %p)\n", debugstr_w(pszString), pkey); TRACE("(%s, %p)\n", debugstr_w(pszString), pkey);
@ -233,15 +233,37 @@ HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
if (!*pszString) if (!*pszString)
return E_INVALIDARG; return E_INVALIDARG;
/* Only the space seems to be recognized as whitespace. */ /* Only the space seems to be recognized as whitespace. The comma is only
while (*pszString == ' ') * recognized once and processing terminates if another comma is found. */
while (*pszString == ' ' || *pszString == ',')
{
if (*pszString == ',')
{
if (has_comma)
return S_OK;
else
has_comma = 1;
}
pszString++; pszString++;
}
if (!*pszString) if (!*pszString)
return E_INVALIDARG; return E_INVALIDARG;
/* Only two minus signs are recognized. The first is ignored, and the /* Only two minus signs are recognized if no comma is detected. The first
* second is interpreted. */ * sign is ignored, and the second is interpreted. If a comma is detected
* before the minus sign, then only one minus sign counts, and property ID
* interpretation begins with the next character. */
if (has_comma)
{
if (*pszString == '-')
{
has_minus = 1;
pszString++;
}
}
else
{
if (*pszString == '-') if (*pszString == '-')
pszString++; pszString++;
@ -258,6 +280,7 @@ HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
/* Skip any remaining spaces after minus sign. */ /* Skip any remaining spaces after minus sign. */
while (*pszString == ' ') while (*pszString == ' ')
pszString++; pszString++;
}
/* Overflow is not checked. */ /* Overflow is not checked. */
while (isdigitW(*pszString)) while (isdigitW(*pszString))

View File

@ -290,6 +290,42 @@ static void test_PSPropertyKeyFromString(void)
static const WCHAR fmtid_overflowpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-', static const WCHAR fmtid_overflowpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-', '1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','2','3','4','5','6','7','8','9','0','1',0}; '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','2','3','4','5','6','7','8','9','0','1',0};
static const WCHAR fmtid_commapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',',','1','3','5','7','9',0};
static const WCHAR fmtid_commaspidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',',',',',',','1','3','5','7','9',0};
static const WCHAR fmtid_commaspacepidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',',',' ','1','3','5','7','9',0};
static const WCHAR fmtid_spacecommapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',','1','3','5','7','9',0};
static const WCHAR fmtid_spccommaspcpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ','1','3','5','7','9',0};
static const WCHAR fmtid_spacescommaspidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ',',','1','3','5','7','9',0};
static const WCHAR fmtid_commanegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',',','-','1','3','5','7','9',0};
static const WCHAR fmtid_spccommanegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',','-','1','3','5','7','9',0};
static const WCHAR fmtid_commaspcnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',',',' ','-','1','3','5','7','9',0};
static const WCHAR fmtid_spccommaspcnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ','-','1','3','5','7','9',0};
static const WCHAR fmtid_commanegspcpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',',','-',' ','1','3','5','7','9',0};
static const WCHAR fmtid_negcommapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}','-',',','1','3','5','7','9',0};
static const WCHAR fmtid_normalpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-', static const WCHAR fmtid_normalpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-','1','2','3','4','-', '1','2','3','4','-','1','2','3','4','-',
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','3','5','7','9',0}; '1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','3','5','7','9',0};
@ -357,6 +393,18 @@ static void test_PSPropertyKeyFromString(void)
{fmtid_hexpidW, &out, S_OK, {expect_guid, 0}}, {fmtid_hexpidW, &out, S_OK, {expect_guid, 0}},
{fmtid_mixedpidW, &out, S_OK, {expect_guid, 0}}, {fmtid_mixedpidW, &out, S_OK, {expect_guid, 0}},
{fmtid_overflowpidW, &out, S_OK, {expect_guid, 3755744309U}}, {fmtid_overflowpidW, &out, S_OK, {expect_guid, 3755744309U}},
{fmtid_commapidW, &out, S_OK, {expect_guid, 13579}},
{fmtid_commaspidW, &out, S_OK, {expect_guid, 0}},
{fmtid_commaspacepidW, &out, S_OK, {expect_guid, 13579}},
{fmtid_spacecommapidW, &out, S_OK, {expect_guid, 13579}},
{fmtid_spccommaspcpidW, &out, S_OK, {expect_guid, 13579}},
{fmtid_spacescommaspidW, &out, S_OK, {expect_guid, 0}},
{fmtid_commanegpidW, &out, S_OK, {expect_guid, 4294953717U}},
{fmtid_spccommanegpidW, &out, S_OK, {expect_guid, 4294953717U}},
{fmtid_commaspcnegpidW, &out, S_OK, {expect_guid, 4294953717U}},
{fmtid_spccommaspcnegpidW, &out, S_OK, {expect_guid, 4294953717U}},
{fmtid_commanegspcpidW, &out, S_OK, {expect_guid, 0U}},
{fmtid_negcommapidW, &out, S_OK, {expect_guid, 0}},
{fmtid_normalpidW, &out, S_OK, {expect_guid, 13579}}, {fmtid_normalpidW, &out, S_OK, {expect_guid, 13579}},
}; };