Closed ghost closed 3 years ago
The current Windows incarnation is brittle:
https://github.com/pkg/browser/blob/0a3d74bf9ce488f035cf5bc36f753a711bc74334/browser_windows.go#L9-L12
it survives ampersands, but not other characters:
package main import "github.com/pkg/browser" func main() { browser.OpenURL("http://example.com?aa bb&cc") }
better would be to call RunDLL32, no replacer needed. Examples:
rundll32 url,OpenURL "http://example.com?aa bb&cc" rundll32 url,FileProtocolHandler "http://example.com?aa bb&cc"
https://github.com/skratchdot/open-golang/blob/master/open/exec_windows.go
Or call browser directly via the BROWSER environment variable. This is what Python does:
import webbrowser webbrowser.open('http://example.com?aa bb&cc')
https://github.com/python/cpython/blob/master/Lib/webbrowser.py
Or better still would be to call ShellExecuteW on Windows:
ShellExecuteW
https://docs.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shellexecutew
This is what D does:
import std.process; void main() { browse("http://example.com?aa bb&cc"); }
https://github.com/dlang/phobos/blob/master/std/process.d
and Nim:
import browsers openDefaultBrowser("http://example.com?aa bb&cc")
https://github.com/nim-lang/Nim/blob/devel/lib/pure/browsers.nim
PRs definately welcome for this, might get to it myself eventually, but no guarantees :)
The current Windows incarnation is brittle:
https://github.com/pkg/browser/blob/0a3d74bf9ce488f035cf5bc36f753a711bc74334/browser_windows.go#L9-L12
it survives ampersands, but not other characters:
better would be to call RunDLL32, no replacer needed. Examples:
https://github.com/skratchdot/open-golang/blob/master/open/exec_windows.go
Or call browser directly via the BROWSER environment variable. This is what Python does:
https://github.com/python/cpython/blob/master/Lib/webbrowser.py
Or better still would be to call
ShellExecuteW
on Windows:https://docs.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shellexecutew
This is what D does:
https://github.com/dlang/phobos/blob/master/std/process.d
and Nim:
https://github.com/nim-lang/Nim/blob/devel/lib/pure/browsers.nim