shlwapi: Added special case for URL_PART_HOSTNAME in UrlGetPart.

This commit is contained in:
Piotr Caban 2009-12-15 23:47:36 +01:00 committed by Alexandre Julliard
parent 1e0827f645
commit 8de69a174a
2 changed files with 48 additions and 5 deletions

View File

@ -552,6 +552,17 @@ static void test_UrlGetPart(void)
test_url_part(http_url, URL_PART_HOSTNAME, 0, "www.wine hq.org");
test_url_part(http_url, URL_PART_PASSWORD, 0, "pass 123");
dwSize = sizeof(szPart);
res = UrlGetPartA("file://c:\\index.htm", szPart, &dwSize, URL_PART_HOSTNAME, 0);
ok(res==S_FALSE, "returned %08x\n", res);
dwSize = sizeof(szPart);
szPart[0] = 'x'; szPart[1] = '\0';
res = UrlGetPartA("file:some text", szPart, &dwSize, URL_PART_HOSTNAME, 0);
ok(res==S_FALSE, "returned %08x\n", res);
ok(szPart[0] == '\0', "szPart[0] = %c\n", szPart[0]);
ok(dwSize == 0, "dwSize = %d\n", dwSize);
}
/* ########################### */

View File

@ -2004,7 +2004,7 @@ HRESULT WINAPI UrlGetPartA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut,
len = INTERNET_MAX_URL_LENGTH;
ret = UrlGetPartW(in, out, &len, dwPart, dwFlags);
if (ret != S_OK) {
if (FAILED(ret)) {
HeapFree(GetProcessHeap(), 0, in);
return ret;
}
@ -2015,10 +2015,10 @@ HRESULT WINAPI UrlGetPartA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut,
HeapFree(GetProcessHeap(), 0, in);
return E_POINTER;
}
WideCharToMultiByte(0, 0, out, len+1, pszOut, *pcchOut, 0, 0);
*pcchOut = len2;
len2 = WideCharToMultiByte(0, 0, out, len+1, pszOut, *pcchOut, 0, 0);
*pcchOut = len2-1;
HeapFree(GetProcessHeap(), 0, in);
return S_OK;
return ret;
}
/*************************************************************************
@ -2031,12 +2031,18 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut,
{
WINE_PARSE_URL pl;
HRESULT ret;
DWORD size, schsize;
DWORD scheme, size, schsize;
LPCWSTR addr, schaddr;
TRACE("(%s %p %p(%d) %08x %08x)\n",
debugstr_w(pszIn), pszOut, pcchOut, *pcchOut, dwPart, dwFlags);
addr = strchrW(pszIn, ':');
if(!addr)
return E_FAIL;
scheme = get_scheme_code(pszIn, addr-pszIn);
ret = URL_ParseUrl(pszIn, &pl);
if (ret == S_OK) {
schaddr = pl.pScheme;
@ -2050,6 +2056,26 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut,
break;
case URL_PART_HOSTNAME:
switch(scheme) {
case URL_SCHEME_FTP:
case URL_SCHEME_HTTP:
case URL_SCHEME_GOPHER:
case URL_SCHEME_TELNET:
case URL_SCHEME_FILE:
case URL_SCHEME_HTTPS:
break;
default:
return E_FAIL;
}
if(scheme==URL_SCHEME_FILE && (!pl.szHostName ||
(pl.szHostName==1 && *(pl.pHostName+1)==':'))) {
if(pcchOut)
*pszOut = '\0';
*pcchOut = 0;
return S_FALSE;
}
if (!pl.szHostName) return E_INVALIDARG;
addr = pl.pHostName;
size = pl.szHostName;
@ -2101,7 +2127,13 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut,
*pcchOut = size;
}
TRACE("len=%d %s\n", *pcchOut, debugstr_w(pszOut));
}else if(dwPart==URL_PART_HOSTNAME && scheme==URL_SCHEME_FILE) {
if(*pcchOut)
*pszOut = '\0';
*pcchOut = 0;
return S_FALSE;
}
return ret;
}