mshtml: Reimplement HTMLLocation::get_pathname.

This commit is contained in:
Andrew Eikum 2009-10-16 11:45:37 -05:00 committed by Alexandre Julliard
parent 6a456fa6d9
commit a03d0bcaa9
2 changed files with 10 additions and 25 deletions

View File

@ -428,10 +428,7 @@ static HRESULT WINAPI HTMLLocation_put_pathname(IHTMLLocation *iface, BSTR v)
static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p) static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p)
{ {
HTMLLocation *This = HTMLLOCATION_THIS(iface); HTMLLocation *This = HTMLLOCATION_THIS(iface);
WCHAR buf[INTERNET_MAX_PATH_LENGTH]; URL_COMPONENTSW url = {sizeof(URL_COMPONENTSW)};
URL_COMPONENTSW url = {sizeof(url)};
const WCHAR *doc_url;
DWORD size = 0;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
@ -439,29 +436,17 @@ static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p)
if(!p) if(!p)
return E_POINTER; return E_POINTER;
hres = get_url(This, &doc_url);
if(FAILED(hres))
return hres;
hres = CoInternetParseUrl(doc_url, PARSE_PATH_FROM_URL, 0, buf, sizeof(buf), &size, 0);
if(SUCCEEDED(hres)) {
*p = SysAllocString(buf);
if(!*p)
return E_OUTOFMEMORY;
return S_OK;
}
url.dwUrlPathLength = 1; url.dwUrlPathLength = 1;
url.dwExtraInfoLength = 1;
hres = get_url_components(This, &url); hres = get_url_components(This, &url);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(!url.dwUrlPathLength) { if(url.dwUrlPathLength && url.lpszUrlPath[0] == '/')
*p = NULL; *p = SysAllocStringLen(url.lpszUrlPath + 1, url.dwUrlPathLength - 1);
return S_OK; else
} *p = SysAllocStringLen(url.lpszUrlPath, url.dwUrlPathLength);
*p = SysAllocStringLen(url.lpszUrlPath, url.dwUrlPathLength);
if(!*p) if(!*p)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
return S_OK; return S_OK;

View File

@ -61,7 +61,7 @@ static const struct location_test http_test = {
"www.winehq.org:80", TRUE, "www.winehq.org:80", TRUE,
"www.winehq.org", TRUE, "www.winehq.org", TRUE,
"80", TRUE, "80", TRUE,
"", FALSE, "", TRUE,
"?search", FALSE, "?search", FALSE,
"#hash", FALSE "#hash", FALSE
}; };
@ -75,7 +75,7 @@ static const struct location_test http_file_test = {
"www.winehq.org:80", TRUE, "www.winehq.org:80", TRUE,
"www.winehq.org", TRUE, "www.winehq.org", TRUE,
"80", TRUE, "80", TRUE,
"file", FALSE, "file", TRUE,
"?search", FALSE, "?search", FALSE,
"#hash", FALSE "#hash", FALSE
}; };
@ -89,7 +89,7 @@ static const struct location_test ftp_test = {
"ftp.winehq.org:21", TRUE, "ftp.winehq.org:21", TRUE,
"ftp.winehq.org", TRUE, "ftp.winehq.org", TRUE,
"21", TRUE, "21", TRUE,
"", FALSE, "", TRUE,
NULL, FALSE, NULL, FALSE,
NULL, FALSE NULL, FALSE
}; };
@ -103,7 +103,7 @@ static const struct location_test ftp_file_test = {
"ftp.winehq.org:21", TRUE, "ftp.winehq.org:21", TRUE,
"ftp.winehq.org", TRUE, "ftp.winehq.org", TRUE,
"21", TRUE, "21", TRUE,
"file", FALSE, "file", TRUE,
NULL, FALSE, NULL, FALSE,
NULL, FALSE NULL, FALSE
}; };