propsys: Fix comma processing in PSPropertyKeyFromString.

oldstable
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)
{
int has_minus = 0;
int has_minus = 0, has_comma = 0;
TRACE("(%s, %p)\n", debugstr_w(pszString), pkey);
@ -233,31 +233,54 @@ HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
if (!*pszString)
return E_INVALIDARG;
/* Only the space seems to be recognized as whitespace. */
while (*pszString == ' ')
/* Only the space seems to be recognized as whitespace. The comma is only
* 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++;
}
if (!*pszString)
return E_INVALIDARG;
/* Only two minus signs are recognized. The first is ignored, and the
* second is interpreted. */
if (*pszString == '-')
pszString++;
/* Skip any intermediate spaces after the first minus sign. */
while (*pszString == ' ')
pszString++;
if (*pszString == '-')
/* Only two minus signs are recognized if no comma is detected. The first
* 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)
{
has_minus = 1;
pszString++;
if (*pszString == '-')
{
has_minus = 1;
pszString++;
}
}
else
{
if (*pszString == '-')
pszString++;
/* Skip any remaining spaces after minus sign. */
while (*pszString == ' ')
pszString++;
/* Skip any intermediate spaces after the first minus sign. */
while (*pszString == ' ')
pszString++;
if (*pszString == '-')
{
has_minus = 1;
pszString++;
}
/* Skip any remaining spaces after minus sign. */
while (*pszString == ' ')
pszString++;
}
/* Overflow is not checked. */
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','-',
'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};
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','-',
'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};
@ -357,6 +393,18 @@ static void test_PSPropertyKeyFromString(void)
{fmtid_hexpidW, &out, S_OK, {expect_guid, 0}},
{fmtid_mixedpidW, &out, S_OK, {expect_guid, 0}},
{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}},
};