Skip to content

Honour BROWSER env var and use rundll32 on Windows#56

Merged
andrew merged 1 commit intomainfrom
browser-env
Apr 13, 2026
Merged

Honour BROWSER env var and use rundll32 on Windows#56
andrew merged 1 commit intomainfrom
browser-env

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented Apr 13, 2026

Closes #45.

Two changes to openBrowser, both in the same function so bundled together.

$BROWSER support: if the environment variable is set, that executable is used directly with the URL as its only argument. Falls back to the existing platform default when unset. No support for :-separated lists or %s substitution — the Go toolchain's internal browser package doesn't bother with those either and the simple form covers the common case.

Windows launcher: switched from cmd /c start <url> to rundll32 url.dll,FileProtocolHandler <url>. The old version was unsafe because cmd.exe re-parses its /c argument, so a URL containing & would be split into separate shell commands. The URL is built from repo.HTMLURL and repo.DefaultBranch which come from the forge API, so a compromised self-hosted instance could exploit it. With rundll32 the URL stays a single argv element with no shell in the path.

The argv-building is split out into a browserCmd(goos, url) helper so it can be tested without launching anything.

@andrew andrew merged commit 9d67341 into main Apr 13, 2026
4 checks passed
@andrew andrew deleted the browser-env branch April 13, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle BROWSER env var for the various forge browse commands

1 participant