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, ...@@ -590,6 +590,12 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid,
UINT rc; UINT rc;
media_info source_struct; media_info source_struct;
WCHAR squished_pc[GUID_SIZE]; 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), TRACE("%s %s %x %x %s %i\n", debugstr_w(szProduct), debugstr_w(szUserSid),
dwContext, dwOptions, debugstr_w(szSource), dwIndex); dwContext, dwOptions, debugstr_w(szSource), dwIndex);
...@@ -633,8 +639,19 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid, ...@@ -633,8 +639,19 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid,
return ERROR_FUNCTION_FAILED; 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; 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); DWORD current_index = atoiW(source_struct.szIndex);
/* found the source */ /* found the source */
...@@ -646,7 +663,7 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid, ...@@ -646,7 +663,7 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid,
{ {
DWORD current_index = 0; DWORD current_index = 0;
static const WCHAR fmt[] = {'%','i',0}; static const WCHAR fmt[] = {'%','i',0};
DWORD size = lstrlenW(szSource)*sizeof(WCHAR); DWORD size = lstrlenW(source) * sizeof(WCHAR);
if (source_struct.szIndex[0]) if (source_struct.szIndex[0])
current_index = atoiW(source_struct.szIndex); current_index = atoiW(source_struct.szIndex);
...@@ -657,9 +674,10 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid, ...@@ -657,9 +674,10 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid,
current_index ++; current_index ++;
sprintfW(source_struct.szIndex,fmt,current_index); sprintfW(source_struct.szIndex,fmt,current_index);
rc = RegSetValueExW(typekey, source_struct.szIndex, 0, REG_EXPAND_SZ, rc = RegSetValueExW(typekey, source_struct.szIndex, 0, REG_EXPAND_SZ,
(const BYTE *)szSource, size); (const BYTE *)source, size);
} }
msi_free(source);
RegCloseKey(typekey); RegCloseKey(typekey);
RegCloseKey(sourcekey); RegCloseKey(sourcekey);
return rc; return rc;
......
...@@ -419,11 +419,8 @@ static void test_MsiSourceListAddSourceEx(void) ...@@ -419,11 +419,8 @@ static void test_MsiSourceListAddSourceEx(void)
size = MAX_PATH; size = MAX_PATH;
res = RegQueryValueExA(url, "1", NULL, NULL, (LPBYTE)value, &size); res = RegQueryValueExA(url, "1", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); 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 */ /* add another source, index 0 */
r = pMsiSourceListAddSourceExA(prodcode, usersid, r = pMsiSourceListAddSourceExA(prodcode, usersid,
...@@ -434,20 +431,14 @@ static void test_MsiSourceListAddSourceEx(void) ...@@ -434,20 +431,14 @@ static void test_MsiSourceListAddSourceEx(void)
size = MAX_PATH; size = MAX_PATH;
res = RegQueryValueExA(url, "1", NULL, NULL, (LPBYTE)value, &size); res = RegQueryValueExA(url, "1", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); 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; size = MAX_PATH;
res = RegQueryValueExA(url, "2", NULL, NULL, (LPBYTE)value, &size); res = RegQueryValueExA(url, "2", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); 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 */ /* add another source, index 1 */
r = pMsiSourceListAddSourceExA(prodcode, usersid, r = pMsiSourceListAddSourceExA(prodcode, usersid,
...@@ -533,11 +524,8 @@ static void test_MsiSourceListAddSourceEx(void) ...@@ -533,11 +524,8 @@ static void test_MsiSourceListAddSourceEx(void)
size = MAX_PATH; size = MAX_PATH;
res = RegQueryValueExA(net, "1", NULL, NULL, (LPBYTE)value, &size); res = RegQueryValueExA(net, "1", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); 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 */ /* just MSISOURCETYPE_URL */
r = pMsiSourceListAddSourceExA(prodcode, usersid, r = pMsiSourceListAddSourceExA(prodcode, usersid,
...@@ -581,11 +569,8 @@ static void test_MsiSourceListAddSourceEx(void) ...@@ -581,11 +569,8 @@ static void test_MsiSourceListAddSourceEx(void)
size = MAX_PATH; size = MAX_PATH;
res = RegQueryValueExA(url, "5", NULL, NULL, (LPBYTE)value, &size); res = RegQueryValueExA(url, "5", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); 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 */ /* NULL szUserSid */
r = pMsiSourceListAddSourceExA(prodcode, NULL, r = pMsiSourceListAddSourceExA(prodcode, NULL,
...@@ -596,20 +581,14 @@ static void test_MsiSourceListAddSourceEx(void) ...@@ -596,20 +581,14 @@ static void test_MsiSourceListAddSourceEx(void)
size = MAX_PATH; size = MAX_PATH;
res = RegQueryValueExA(net, "1", NULL, NULL, (LPBYTE)value, &size); res = RegQueryValueExA(net, "1", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); 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; size = MAX_PATH;
res = RegQueryValueExA(net, "2", NULL, NULL, (LPBYTE)value, &size); res = RegQueryValueExA(net, "2", NULL, NULL, (LPBYTE)value, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); 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 */ /* invalid options, must have source type */
r = pMsiSourceListAddSourceExA(prodcode, usersid, 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