/******************************************************************** * CoInternetGetSecurityUrl (URLMON.@) */ HRESULT WINAPI CoInternetGetSecurityUrl(LPCWSTR pwzUrl, LPWSTR *ppwzSecUrl, PSUACTION psuAction, DWORD dwReserved) { WCHAR *secure_url; HRESULT hres; TRACE("(%p,%p,%u,%u)\n", pwzUrl, ppwzSecUrl, psuAction, dwReserved); hres = parse_security_url(pwzUrl, psuAction, &secure_url); if(FAILED(hres)) return hres; if(psuAction != PSU_SECURITY_URL_ONLY) { PARSEDURLW parsed_url = { sizeof(parsed_url) }; DWORD size; /* FIXME: Use helpers from uri.c */ if(SUCCEEDED(ParseURLW(secure_url, &parsed_url))) { WCHAR *new_url; switch(parsed_url.nScheme) { case URL_SCHEME_FTP: case URL_SCHEME_HTTP: case URL_SCHEME_HTTPS: size = strlenW(secure_url)+1; new_url = CoTaskMemAlloc(size * sizeof(WCHAR)); if(new_url) hres = UrlGetPartW(secure_url, new_url, &size, URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME); else hres = E_OUTOFMEMORY; CoTaskMemFree(secure_url); if(hres != S_OK) { WARN("UrlGetPart failed: %08x\n", hres); CoTaskMemFree(new_url); return FAILED(hres) ? hres : E_FAIL; } secure_url = new_url; } } } *ppwzSecUrl = secure_url; return S_OK; }
/************************************************************************** * CDesktopFolder::ParseDisplayName * * NOTES * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds * to MyComputer */ HRESULT WINAPI CDesktopFolder::ParseDisplayName( HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, DWORD *pchEaten, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes) { LPCWSTR szNext = NULL; LPITEMIDLIST pidlTemp = NULL; PARSEDURLW urldata; HRESULT hr = S_OK; TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", this, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), pchEaten, ppidl, pdwAttributes); if (!ppidl) return E_INVALIDARG; *ppidl = NULL; if (!lpszDisplayName) return E_INVALIDARG; if (pchEaten) *pchEaten = 0; /* strange but like the original */ urldata.cbSize = sizeof(urldata); if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') { return m_regFolder->ParseDisplayName(hwndOwner, pbc, lpszDisplayName, pchEaten, ppidl, pdwAttributes); } else if (PathGetDriveNumberW (lpszDisplayName) >= 0) { /* it's a filesystem path with a drive. Let MyComputer/UnixDosFolder parse it */ pidlTemp = _ILCreateMyComputer (); szNext = lpszDisplayName; } else if (PathIsUNCW(lpszDisplayName)) { pidlTemp = _ILCreateNetwork(); szNext = lpszDisplayName; } else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) ) { *ppidl = pidlTemp; return S_OK; } else if (SUCCEEDED(ParseURLW(lpszDisplayName, &urldata))) { if (urldata.nScheme == URL_SCHEME_SHELL) /* handle shell: urls */ { TRACE ("-- shell url: %s\n", debugstr_w(urldata.pszSuffix)); pidlTemp = _ILCreateGuidFromStrW(urldata.pszSuffix + 2); } else return IEParseDisplayNameWithBCW(CP_ACP, lpszDisplayName, pbc, ppidl); } else { if (*lpszDisplayName) { /* it's a filesystem path on the desktop. Let a FSFolder parse it */ hr = m_DesktopFSFolder->ParseDisplayName(hwndOwner, pbc, lpszDisplayName, pchEaten, ppidl, pdwAttributes); if (SUCCEEDED(hr)) return hr; return m_SharedDesktopFSFolder->ParseDisplayName(hwndOwner, pbc, lpszDisplayName, pchEaten, ppidl, pdwAttributes); } else pidlTemp = _ILCreateMyComputer(); szNext = NULL; } if (SUCCEEDED(hr) && pidlTemp) { if (szNext && *szNext) { hr = SHELL32_ParseNextElement(this, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); } else { if (pdwAttributes && *pdwAttributes) { GetAttributesOf(1, &pidlTemp, pdwAttributes); } } } if (SUCCEEDED(hr)) *ppidl = pidlTemp; else *ppidl = NULL; TRACE ("(%p)->(-- ret=0x%08x)\n", this, hr); return hr; }
/************************************************************************** * ISF_Desktop_fnParseDisplayName * * NOTES * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds * to MyComputer */ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) { IDesktopFolderImpl *This = impl_from_IShellFolder2(iface); IShellFolder *shell_folder = (IShellFolder*)iface; WCHAR szElement[MAX_PATH]; LPCWSTR szNext = NULL; LPITEMIDLIST pidlTemp = NULL; PARSEDURLW urldata; HRESULT hr = S_OK; CLSID clsid; TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), pchEaten, ppidl, pdwAttributes); if (!ppidl) return E_INVALIDARG; *ppidl = 0; if (!lpszDisplayName) return E_INVALIDARG; if (pchEaten) *pchEaten = 0; /* strange but like the original */ urldata.cbSize = sizeof(urldata); if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') { szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); TRACE ("-- element: %s\n", debugstr_w (szElement)); SHCLSIDFromStringW (szElement + 2, &clsid); pidlTemp = _ILCreateGuid (PT_GUID, &clsid); } else if (PathGetDriveNumberW (lpszDisplayName) >= 0) { /* it's a filesystem path with a drive. Let MyComputer/UnixDosFolder parse it */ if (UNIXFS_is_rooted_at_desktop()) pidlTemp = _ILCreateGuid(PT_GUID, &CLSID_UnixDosFolder); else pidlTemp = _ILCreateMyComputer (); szNext = lpszDisplayName; } else if (PathIsUNCW(lpszDisplayName)) { pidlTemp = _ILCreateNetwork(); szNext = lpszDisplayName; } else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) ) { *ppidl = pidlTemp; return S_OK; } else if (SUCCEEDED(ParseURLW(lpszDisplayName, &urldata))) { if (urldata.nScheme == URL_SCHEME_SHELL) /* handle shell: urls */ { TRACE ("-- shell url: %s\n", debugstr_w(urldata.pszSuffix)); SHCLSIDFromStringW (urldata.pszSuffix+2, &clsid); pidlTemp = _ILCreateGuid (PT_GUID, &clsid); } else return IEParseDisplayNameWithBCW(CP_ACP,lpszDisplayName,pbc,ppidl); } else { /* it's a filesystem path on the desktop. Let a FSFolder parse it */ if (*lpszDisplayName) { if (*lpszDisplayName == '/') { /* UNIX paths should be parsed by unixfs */ IShellFolder *unixFS; hr = UnixFolder_Constructor(NULL, &IID_IShellFolder, (LPVOID*)&unixFS); if (SUCCEEDED(hr)) { hr = IShellFolder_ParseDisplayName(unixFS, NULL, NULL, lpszDisplayName, NULL, &pidlTemp, NULL); IShellFolder_Release(unixFS); } } else { /* build a complete path to create a simple pidl */ WCHAR szPath[MAX_PATH]; LPWSTR pathPtr; lstrcpynW(szPath, This->sPathTarget, MAX_PATH); pathPtr = PathAddBackslashW(szPath); if (pathPtr) { lstrcpynW(pathPtr, lpszDisplayName, MAX_PATH - (pathPtr - szPath)); hr = _ILCreateFromPathW(szPath, &pidlTemp); } else { /* should never reach here, but for completeness */ hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); } } } else pidlTemp = _ILCreateMyComputer(); szNext = NULL; } if (SUCCEEDED(hr) && pidlTemp) { if (szNext && *szNext) { hr = SHELL32_ParseNextElement(iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); } else { if (pdwAttributes && *pdwAttributes) hr = SHELL32_GetItemAttributes(shell_folder, pidlTemp, pdwAttributes); } } *ppidl = pidlTemp; TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr); return hr; }
static HRESULT parse_rootdocument(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size, DWORD *rsize) { IInternetProtocolInfo *protocol_info; PARSEDURLW url_info; HRESULT hres; TRACE("(%s %08x %p %d %p)\n", debugstr_w(url), flags, result, size, rsize); protocol_info = get_protocol_info(url); if(protocol_info) { hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_ROOTDOCUMENT, flags, result, size, rsize, 0); IInternetProtocolInfo_Release(protocol_info); if(SUCCEEDED(hres)) return hres; } url_info.cbSize = sizeof(url_info); if(FAILED(ParseURLW(url, &url_info))) return E_FAIL; switch(url_info.nScheme) { case URL_SCHEME_FTP: case URL_SCHEME_HTTP: case URL_SCHEME_HTTPS: if(url_info.cchSuffix<3 || *(url_info.pszSuffix)!='/' || *(url_info.pszSuffix+1)!='/') return E_FAIL; if(size < url_info.cchProtocol+3) { size = 0; hres = UrlGetPartW(url, result, &size, URL_PART_HOSTNAME, flags); if(rsize) *rsize = size+url_info.cchProtocol+3; if(hres == E_POINTER) return S_FALSE; return hres; } size -= url_info.cchProtocol+3; hres = UrlGetPartW(url, result+url_info.cchProtocol+3, &size, URL_PART_HOSTNAME, flags); if(hres == E_POINTER) return S_FALSE; if(FAILED(hres)) return E_FAIL; if(rsize) *rsize = size+url_info.cchProtocol+3; memcpy(result, url, (url_info.cchProtocol+3)*sizeof(WCHAR)); return hres; default: return E_FAIL; } }