Commit a688cb69 authored by Brendan Shanks's avatar Brendan Shanks Committed by Alexandre Julliard

winebrowser: Prefix an invalid URL with 'http://' before opening with a browser.

Fixes usage like 'winebrowser winehq.org' when xdg-open or macOS 'open' is used. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50094Signed-off-by: 's avatarBrendan Shanks <bshanks@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 786451c1
......@@ -184,6 +184,29 @@ static int open_mailto_url( const WCHAR *url )
return launch_app( mailers, url );
}
static int open_invalid_url( const WCHAR *url )
{
static const WCHAR httpW[] =
{'h','t','t','p',':','/','/',0};
WCHAR *url_prefixed;
int ret;
url_prefixed = HeapAlloc( GetProcessHeap(), 0, (ARRAY_SIZE(httpW) + strlenW( url )) * sizeof(WCHAR) );
if (!url_prefixed)
{
WINE_ERR("Out of memory\n");
return 1;
}
strcpyW( url_prefixed, httpW );
strcatW( url_prefixed, url );
ret = open_http_url( url_prefixed );
HeapFree( GetProcessHeap(), 0, url_prefixed );
return ret;
}
/*****************************************************************************
* DDE helper functions.
*/
......@@ -448,8 +471,8 @@ int __cdecl wmain(int argc, WCHAR *argv[])
hres = CreateUri(url, Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME|Uri_CREATE_FILE_USE_DOS_PATH, 0, &uri);
if(FAILED(hres)) {
WINE_ERR("Failed to parse URL\n");
ret = open_http_url(url);
WINE_ERR("Failed to parse URL %s, treating as HTTP\n", wine_dbgstr_w(url));
ret = open_invalid_url(url);
HeapFree(GetProcessHeap(), 0, ddeString);
return ret;
}
......
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