From: Nello De Gregoris <bluechxindv@gmail.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59552 --- dlls/urlmon/session.c | 21 +++++++++++++++++++++ dlls/urlmon/urlmon_main.c | 6 ++---- dlls/urlmon/urlmon_main.h | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/dlls/urlmon/session.c b/dlls/urlmon/session.c index 660fab54570..3e2cd7721d0 100644 --- a/dlls/urlmon/session.c +++ b/dlls/urlmon/session.c @@ -157,6 +157,27 @@ static HRESULT unregister_namespace(IClassFactory *cf, LPCWSTR protocol) return S_OK; } +BOOL is_known_protocol(LPCWSTR url) +{ + WCHAR schema[64]; + DWORD schema_len; + HRESULT hres; + BOOL found; + + hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, ARRAY_SIZE(schema), &schema_len, 0); + if(FAILED(hres) || !schema_len) + return FALSE; + + EnterCriticalSection(&session_cs); + found = find_name_space(schema) != NULL; + LeaveCriticalSection(&session_cs); + + if(!found) + found = get_protocol_cf(schema, schema_len, NULL, NULL) == S_OK; + + return found; +} + BOOL is_registered_protocol(LPCWSTR url) { DWORD schema_len; diff --git a/dlls/urlmon/urlmon_main.c b/dlls/urlmon/urlmon_main.c index 806a893d7d1..bcc1314d773 100644 --- a/dlls/urlmon/urlmon_main.c +++ b/dlls/urlmon/urlmon_main.c @@ -511,17 +511,15 @@ HRESULT WINAPI DllRegisterServerEx(void) * Failure: S_FALSE. * returns E_INVALIDARG if one or more of the args is invalid. * - * TODO: - * test functionality against windows to see what a valid URL is. */ HRESULT WINAPI IsValidURL(LPBC pBC, LPCWSTR szURL, DWORD dwReserved) { - FIXME("(%p, %s, %ld): stub\n", pBC, debugstr_w(szURL), dwReserved); + TRACE("(%p, %s, %ld)\n", pBC, debugstr_w(szURL), dwReserved); if (dwReserved || !szURL) return E_INVALIDARG; - return S_OK; + return is_known_protocol(szURL) ? S_OK : S_FALSE; } /************************************************************************** diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h index ceb3e09b761..e30a4da9aa2 100644 --- a/dlls/urlmon/urlmon_main.h +++ b/dlls/urlmon/urlmon_main.h @@ -68,6 +68,7 @@ IInternetProtocolInfo *get_protocol_info(LPCWSTR); HRESULT get_protocol_handler(IUri*,CLSID*,IClassFactory**); IInternetProtocol *get_mime_filter(LPCWSTR); BOOL is_registered_protocol(LPCWSTR); +BOOL is_known_protocol(LPCWSTR); HRESULT register_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL); HINTERNET get_internet_session(IInternetBindInfo*); WCHAR *get_useragent(void); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10482