Commit 3555226a authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

wininet: Clean up returned UrlPath for file protocol URLs.

parent 52aab76e
......@@ -1370,8 +1370,9 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
InternetCrackUrlW should not include it */
if (dwUrlLength == -1) nLength--;
lpwszUrl = HeapAlloc(GetProcessHeap(), 0, nLength * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength);
lpwszUrl = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength + 1);
lpwszUrl[nLength] = '\0';
memset(&UCW,0,sizeof(UCW));
UCW.dwStructSize = sizeof(URL_COMPONENTSW);
......@@ -1788,7 +1789,7 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
*/
if (lpszcp != 0 && lpszcp - lpszUrl < dwUrlLength && (!lpszParam || lpszcp <= lpszParam))
{
INT len;
DWORD len;
/* Only truncate the parameter list if it's already been saved
* in lpUC->lpszExtraInfo.
......@@ -1806,8 +1807,46 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
else
len = dwUrlLength-(lpszcp-lpszUrl);
}
SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
lpszcp, len);
if (lpUC->dwUrlPathLength && lpUC->lpszUrlPath &&
lpUC->nScheme == INTERNET_SCHEME_FILE)
{
WCHAR tmppath[MAX_PATH];
if (*lpszcp == '/')
{
len = MAX_PATH;
PathCreateFromUrlW(lpszUrl_orig, tmppath, &len, 0);
}
else
{
WCHAR *iter;
memcpy(tmppath, lpszcp, len * sizeof(WCHAR));
tmppath[len] = '\0';
iter = tmppath;
while (*iter) {
if (*iter == '/')
*iter = '\\';
++iter;
}
}
/* if ends in \. or \.. append a backslash */
if (tmppath[len - 1] == '.' &&
(tmppath[len - 2] == '\\' ||
(tmppath[len - 2] == '.' && tmppath[len - 3] == '\\')))
{
if (len < MAX_PATH - 1)
{
tmppath[len] = '\\';
tmppath[len+1] = '\0';
++len;
}
}
SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
tmppath, len);
}
else
SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
lpszcp, len);
}
else
{
......
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