Fixes usage like 'winebrowser winehq.org' when xdg-open or macOS 'open' is used.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50094 Signed-off-by: Brendan Shanks bshanks@codeweavers.com --- programs/winebrowser/main.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/programs/winebrowser/main.c b/programs/winebrowser/main.c index 9cd6812d032..7895afae842 100644 --- a/programs/winebrowser/main.c +++ b/programs/winebrowser/main.c @@ -118,7 +118,7 @@ static LSTATUS get_commands( HKEY key, const WCHAR *value, WCHAR *buffer, DWORD return res; }
-static int open_http_url( const WCHAR *url ) +static int open_http_url( const WCHAR *url, BOOL url_valid ) { #ifdef __APPLE__ static const WCHAR defaultbrowsers[] = @@ -136,9 +136,13 @@ static int open_http_url( const WCHAR *url ) #endif static const WCHAR browsersW[] = {'B','r','o','w','s','e','r','s',0}; + static const WCHAR httpW[] = + {'h','t','t','p',':','/','/',0};
WCHAR browsers[256]; + WCHAR *url_prefixed; HKEY key; + int ret; LONG r;
/* @@ Wine registry key: HKCU\Software\Wine\WineBrowser */ @@ -150,7 +154,27 @@ static int open_http_url( const WCHAR *url ) if (r != ERROR_SUCCESS) memcpy( browsers, defaultbrowsers, sizeof(defaultbrowsers) );
- return launch_app( browsers, url ); + /* If url parsing failed, prefix url with 'http://'. Required by xdg-open and macOS open. */ + if (url_valid) + { + ret = launch_app( browsers, url ); + } + else + { + 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 = launch_app( browsers, url_prefixed ); + HeapFree( GetProcessHeap(), 0, url_prefixed ); + } + return ret; }
static int open_mailto_url( const WCHAR *url ) @@ -448,8 +472,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_http_url(url, FALSE); HeapFree(GetProcessHeap(), 0, ddeString); return ret; } @@ -476,7 +500,7 @@ int __cdecl wmain(int argc, WCHAR *argv[]) ret = open_mailto_url(display_uri); else /* let the browser decide how to handle the given url */ - ret = open_http_url(display_uri); + ret = open_http_url(display_uri, TRUE);
SysFreeString(display_uri); return ret;
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50094 Signed-off-by: Brendan Shanks bshanks@codeweavers.com --- loader/wine.inf.in | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/loader/wine.inf.in b/loader/wine.inf.in index ee816a5cdef..1af20ee4fdd 100644 --- a/loader/wine.inf.in +++ b/loader/wine.inf.in @@ -780,6 +780,11 @@ HKLM,SOFTWARE\Microsoft\Active Setup\Installed Components{6BF52A52-394A-11d3-B1 HKLM,SOFTWARE\Microsoft\Active Setup\Installed Components{6BF52A52-394A-11d3-B153-00C04F79FAA6},"Locale",2,"*" HKLM,SOFTWARE\Microsoft\Active Setup\Installed Components{6BF52A52-394A-11d3-B153-00C04F79FAA6},"Version",2,"12,0,7601,18840"
+; URL Associations +HKCU,Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice,"ProgId",,"ftp" +HKCU,Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice,"ProgId",,"http" +HKCU,Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice,"ProgId",,"https" + [Nls] HKLM,System\CurrentControlSet\Control\Nls\Language,"0401",,"l_intl.nls" HKLM,System\CurrentControlSet\Control\Nls\Language,"0402",,"l_intl.nls"