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

Alexandre Julliard julliard at winehq.org
Tue Mar 23 15:07:43 CDT 2021


Module: wine
Branch: oldstable
Commit: d86e328001975a47a78c9ef638aa601660f9ca3b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d86e328001975a47a78c9ef638aa601660f9ca3b

Author: Brendan Shanks <bshanks at codeweavers.com>
Date:   Tue Nov 24 15:16:39 2020 -0800

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=50094
Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit a688cb6971525e49ffd029161b9007cd748ad42f)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 programs/winebrowser/main.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/programs/winebrowser/main.c b/programs/winebrowser/main.c
index 9cd6812d032..c70457e50b3 100644
--- a/programs/winebrowser/main.c
+++ b/programs/winebrowser/main.c
@@ -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;
     }




More information about the wine-cvs mailing list