Commit dde89244 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Append a slash to network and url sources.

parent 798429f9
......@@ -590,6 +590,12 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid,
UINT rc;
media_info source_struct;
WCHAR squished_pc[GUID_SIZE];
LPWSTR source;
LPCWSTR postfix;
DWORD size;
static const WCHAR backslash[] = {'\\',0};
static const WCHAR forwardslash[] = {'/',0};
TRACE("%s %s %x %x %s %i\n", debugstr_w(szProduct), debugstr_w(szUserSid),
dwContext, dwOptions, debugstr_w(szSource), dwIndex);
......@@ -633,8 +639,19 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid,
return ERROR_FUNCTION_FAILED;
}
postfix = (dwOptions & MSISOURCETYPE_NETWORK) ? backslash : forwardslash;
if (szSource[lstrlenW(szSource) - 1] == *postfix)
source = strdupW(szSource);
else
{
size = lstrlenW(szSource) + 2;
source = msi_alloc(size * sizeof(WCHAR));
lstrcpyW(source, szSource);
lstrcatW(source, postfix);
}
source_struct.szIndex[0] = 0;
if (find_given_source(typekey, szSource, &source_struct)==ERROR_SUCCESS)
if (find_given_source(typekey, source, &source_struct) == ERROR_SUCCESS)
{
DWORD current_index = atoiW(source_struct.szIndex);
/* found the source */
......@@ -646,7 +663,7 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid,
{
DWORD current_index = 0;
static const WCHAR fmt[] = {'%','i',0};
DWORD size = lstrlenW(szSource)*sizeof(WCHAR);
DWORD size = lstrlenW(source) * sizeof(WCHAR);
if (source_struct.szIndex[0])
current_index = atoiW(source_struct.szIndex);
......@@ -657,9 +674,10 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid,
current_index ++;
sprintfW(source_struct.szIndex,fmt,current_index);
rc = RegSetValueExW(typekey, source_struct.szIndex, 0, REG_EXPAND_SZ,
(const BYTE *)szSource, size);
(const BYTE *)source, size);
}
msi_free(source);
RegCloseKey(typekey);
RegCloseKey(sourcekey);
return rc;
......
......@@ -419,11 +419,8 @@ static void test_MsiSourceListAddSourceEx(void)
size = MAX_PATH;
res = RegQueryValueExA(url, "1", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
todo_wine
{
ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
ok(size == 11, "Expected 11, got %d\n", size);
}
ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
ok(size == 11, "Expected 11, got %d\n", size);
/* add another source, index 0 */
r = pMsiSourceListAddSourceExA(prodcode, usersid,
......@@ -434,20 +431,14 @@ static void test_MsiSourceListAddSourceEx(void)
size = MAX_PATH;
res = RegQueryValueExA(url, "1", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
todo_wine
{
ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
ok(size == 11, "Expected 11, got %d\n", size);
}
ok(!lstrcmpA(value, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value);
ok(size == 11, "Expected 11, got %d\n", size);
size = MAX_PATH;
res = RegQueryValueExA(url, "2", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
todo_wine
{
ok(!lstrcmpA(value, "another/"), "Expected 'another/', got %s\n", value);
ok(size == 9, "Expected 9, got %d\n", size);
}
ok(!lstrcmpA(value, "another/"), "Expected 'another/', got %s\n", value);
ok(size == 9, "Expected 9, got %d\n", size);
/* add another source, index 1 */
r = pMsiSourceListAddSourceExA(prodcode, usersid,
......@@ -533,11 +524,8 @@ static void test_MsiSourceListAddSourceEx(void)
size = MAX_PATH;
res = RegQueryValueExA(net, "1", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
todo_wine
{
ok(!lstrcmpA(value, "source\\"), "Expected 'source\\', got %s\n", value);
ok(size == 8, "Expected 8, got %d\n", size);
}
ok(!lstrcmpA(value, "source\\"), "Expected 'source\\', got %s\n", value);
ok(size == 8, "Expected 8, got %d\n", size);
/* just MSISOURCETYPE_URL */
r = pMsiSourceListAddSourceExA(prodcode, usersid,
......@@ -581,11 +569,8 @@ static void test_MsiSourceListAddSourceEx(void)
size = MAX_PATH;
res = RegQueryValueExA(url, "5", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
todo_wine
{
ok(!lstrcmpA(value, "source/"), "Expected 'source/', got %s\n", value);
ok(size == 8, "Expected 8, got %d\n", size);
}
ok(!lstrcmpA(value, "source/"), "Expected 'source/', got %s\n", value);
ok(size == 8, "Expected 8, got %d\n", size);
/* NULL szUserSid */
r = pMsiSourceListAddSourceExA(prodcode, NULL,
......@@ -596,20 +581,14 @@ static void test_MsiSourceListAddSourceEx(void)
size = MAX_PATH;
res = RegQueryValueExA(net, "1", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
todo_wine
{
ok(!lstrcmpA(value, "source\\"), "Expected 'source\\', got %s\n", value);
ok(size == 8, "Expected 8, got %d\n", size);
}
ok(!lstrcmpA(value, "source\\"), "Expected 'source\\', got %s\n", value);
ok(size == 8, "Expected 8, got %d\n", size);
size = MAX_PATH;
res = RegQueryValueExA(net, "2", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
todo_wine
{
ok(!lstrcmpA(value, "nousersid\\"), "Expected 'nousersid\\', got %s\n", value);
ok(size == 11, "Expected 11, got %d\n", size);
}
ok(!lstrcmpA(value, "nousersid\\"), "Expected 'nousersid\\', got %s\n", value);
ok(size == 11, "Expected 11, got %d\n", size);
/* invalid options, must have source type */
r = pMsiSourceListAddSourceExA(prodcode, usersid,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment