Skip to content

fix(oauth): Windows openBrowser URL quoting (v0.11.2)#212

Merged
liplus-lin-lay merged 1 commit into
mainfrom
211-windows-open-browser
Apr 20, 2026
Merged

fix(oauth): Windows openBrowser URL quoting (v0.11.2)#212
liplus-lin-lay merged 1 commit into
mainfrom
211-windows-open-browser

Conversation

@liplus-lin-lay
Copy link
Copy Markdown
Member

Closes #211

概要

v0.11.1 Windows 版 openBrowser() は authorize URL をクォート無しで cmd.exe /c start "" <URL> に渡していたため、URL に含まれる & が cmd の command separator として解釈され state パラメータが欠落し、Worker /oauth/authorizeinvalid_request: state parameter is required で 400 を返していた。結果「ブラウザ自動オープン」が Windows 上で機能しない regression だった(実機検証 2026-04-20 Master)。

本 PR は URL を "..." で囲んで shell: true 経由で cmd.exe に渡すよう修正した。cmd.exe は quoted 内の & をリテラル扱いするため、authorize URL 全体(client_id + state)がブラウザに正しく届く。

変更

  • mcp-server/server/index.js / local-mcp/src/index.ts — Windows 分岐を command = \start "" "${url}"`; options.shell = true;に変更。macOS / Linux 分岐はそのまま(argv で URL を受け取るため&` の影響なし)。
  • mcp-server/test/open-browser.test.mjs 新規 — platform 分岐と &-regression を検証する spawn-mock unit test を追加(win32 quote 形式、darwin/linux argv 形式、&state=... が command 文字列に保持されること)。
  • docs/installation.{ja,}.md — v0.11.2 Windows hotfix の短い note を追記。
  • version bump: mcp-server/manifest.json / mcp-server/package.json / mcp-server/server.json を 0.11.1 → 0.11.2。

検証

  • cd mcp-server && node --check server/index.js && node --test test/*.test.mjs — 18 tests pass(既存 14 + 新規 4 + spawn-mock 統合 1 を含む)。
  • 実機検証(Windows ブラウザ自動オープンが state を含めて届くこと)は Master が v0.11.2 merge 後に実施予定。

影響スコープ

Windows 限定の hotfix。macOS / Linux の OAuth flow は挙動不変。openBrowser() 失敗時の stderr フォールバック動作も維持。patch release v0.11.2 の想定。

…ze URL

Windows 版 openBrowser() は authorize URL をクォート無しで
`cmd.exe /c start "" <URL>` に渡しており、URL に含まれる `&` が
command separator として解釈され state パラメータ以降が切り落と
されていた。結果 Worker `/oauth/authorize` は state 欠落で 400 を
返し、v0.11.1 の「ブラウザ自動オープン」が Windows 上で機能して
いなかった。

修正: URL を `"..."` で囲んだ上で `shell: true` で cmd.exe 経由に
起動するようにした。これにより cmd.exe は quoted `&` をリテラル
扱いし、authorize URL 全体(client_id + state)がブラウザに届く。
macOS (`open`) と Linux (`xdg-open`) は argv で URL を受け取るため
影響なく、従来実装のまま。

mcp-server と local-mcp の両方を揃え、
`mcp-server/test/open-browser.test.mjs` に platform 分岐と
`&`-regression を検証する spawn-mock unit test を追加。
`docs/installation.{ja,}.md` に v0.11.2 Windows hotfix の短い note
を追記。

バージョンは manifest.json / package.json / server.json を
0.11.1 → 0.11.2 に bump。

Refs #211
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
github-webhook-mcp f660d38 Apr 20 2026, 11:22 PM

Copy link
Copy Markdown
Member Author

@liplus-lin-lay liplus-lin-lay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review: PASS

Acceptance check (issue #211)

Windows openBrowser fix (mcp-server/server/index.js L173-188, local-mcp/src/index.ts same shape)

  • command = \start "" "${url}"`withshell: true— cmd.exe receives the full command string; URL wrapped in inner double quotes so&` is treated as a literal character rather than a command separator.
  • Minimal diff: darwin (open) and linux (xdg-open) branches untouched.
  • Stderr fallback warning preserved for spawn failure and thrown exception paths.
  • Comment clearly explains the &-splitting root cause and cites #211 as the fix reference.

Version bumps

  • 0.11.1 → 0.11.2 across manifest.json, package.json, server.json (2 occurrences in server.json).

Tests

  • mcp-server/test/open-browser.test.mjs added with 4 cases: win32 quoting regression, darwin passthrough, linux passthrough, and spawn error fallback (total test count 14 → 18, all pass).
  • Existing migration.test.mjs / web-auth-required.test.mjs unaffected.

Docs

  • docs/installation.ja.md / .md: short note added on the v0.11.2 Windows hotfix.

Scope deviations

None.

Later / non-blocking

  • Theoretical: URL containing % followed by uppercase alphanumeric could still be treated as %VAR% expansion by cmd.exe. Current OAuth state/client_id are base64url and hex respectively — no % present — so not a live risk. Flag for awareness only.

Next

Mode = auto. Proceeding to squash merge, then release v0.11.2 (human-confirmed release state).

@liplus-lin-lay liplus-lin-lay merged commit 19aa1e4 into main Apr 20, 2026
3 checks passed
@liplus-lin-lay liplus-lin-lay deleted the 211-windows-open-browser branch April 20, 2026 23:24
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.

fix(oauth): Windows browser auto-open drops URL query after & character

1 participant