wmiutils: Accept namespaces without a leading slash.

This commit is contained in:
Hans Leidekker 2013-05-14 14:01:08 +02:00 committed by Alexandre Julliard
parent c476d1785e
commit d816192ecc
2 changed files with 31 additions and 1 deletions

View file

@ -420,6 +420,11 @@ static HRESULT parse_text( struct path *path, ULONG mode, const WCHAR *text )
path->flags |= WBEMPATH_INFO_PATH_HAD_SERVER;
}
p = q;
if (*q && *q != '\\' && *q != '/' && *q != ':')
{
path->num_namespaces = 1;
q++;
}
while (*q && *q != ':')
{
if (*q == '\\' || *q == '/') path->num_namespaces++;
@ -432,6 +437,18 @@ static HRESULT parse_text( struct path *path, ULONG mode, const WCHAR *text )
i = 0;
q = p;
if (*q && *q != '\\' && *q != '/' && *q != ':')
{
p = q;
while (*p && *p != '\\' && *p != '/' && *p != ':') p++;
len = p - q;
if (!(path->namespaces[i] = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto done;
memcpy( path->namespaces[i], q, len * sizeof(WCHAR) );
path->namespaces[i][len] = 0;
path->len_namespaces[i] = len;
q = p;
i++;
}
while (*q && *q != ':')
{
if (*q == '\\' || *q == '/')

View file

@ -122,7 +122,8 @@ static void test_IWbemPath_SetText(void)
{ path8, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS + 1, S_OK },
{ path9, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK },
{ path10, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, WBEM_E_INVALID_PARAMETER, 1 },
{ path11, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK }
{ path11, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK },
{ path15, WBEMPATH_CREATE_ACCEPT_ALL, S_OK }
};
IWbemPath *path;
HRESULT hr;
@ -167,6 +168,8 @@ static void test_IWbemPath_GetText(void)
static const WCHAR expected2W[] =
{'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k','.',
'D','e','v','i','c','e','I','d','=','"','C',':','"',0};
static const WCHAR expected3W[] =
{'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
WCHAR buf[128];
ULONG len, count;
IWbemPath *path;
@ -306,6 +309,16 @@ static void test_IWbemPath_GetText(void)
ok( !lstrcmpW( buf, expected2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( expected2W ) + 1, "unexpected length %u\n", len );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path15 );
ok( hr == S_OK, "got %08x\n", hr );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, expected3W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( expected3W ) + 1, "unexpected length %u\n", len );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path18 );
ok( hr == S_OK, "got %08x\n", hr );