[Bug]: [MCP/CLI] Bare loopback IP addresses (127.0.0.1:port) and hosts with ports fail to navigate due to erroneous scheme inference

クローズ 初心者向け
#43,263 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@alok-108 がすでに取り組んでいます。

2026年10月10日 から。

  • #43264 @alok-108 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
cli

調査の方向性

スキーム推論は packages/playwright-core/src/tools/backend/tab.ts の checkUrlAndNavigate にあります。まずこの関数を読み、次に catch ブロックが http:// と https:// のどちらを選ぶかを確認してください。また、new URL('example.com:8080') は例外を投げない点にも注意してください。完了の条件は、127.0.0.1:3000、0.0.0.0:8000、[::1]:8080 がデフォルトで http:// になり、example.com:8080 がデフォルトで https:// になり、既存の明示的なスキームがそのまま残ることです。動作を確認するため、タブのナビゲーションを扱う既存のテストを探してください。

索引モデルが issue の本文から書いたものです。

説明

What's going on?

In Playwright CLI and MCP server (playwright open, tab-new, browser_navigate), when opening or navigating to URLs specified without an explicit scheme:

  1. Bare loopback IP addresses fail with net::ERR_SSL_PROTOCOL_ERROR:
    When targeting local development servers on loopback IPs (e.g., 127.0.0.1:3000, 0.0.0.0:8000, [::1]:8080), navigation fails immediately:

    page.goto: net::ERR_SSL_PROTOCOL_ERROR at https://127.0.0.1:3000/
    

    This happens because checkUrlAndNavigate only checks url.startsWith('localhost') before defaulting to https://. As local development servers predominantly run on plain HTTP, forcing https:// causes SSL protocol failure.

  2. Bare hostnames with ports fail with net::ERR_ABORTED:
    When specifying a bare host with a port (e.g., example.com:8080), navigation fails:

    page.goto: net::ERR_ABORTED at example.com:8080
    

    According to the WHATWG URL standard, new URL('example.com:8080') parses successfully with protocol: "example.com:" and pathname: "8080". Because new URL(...) does not throw an error, the try / catch block in checkUrlAndNavigate is bypassed entirely, leaving the raw string without an http:// or https:// scheme.

Visual Evidence

1. Reproduction — SSL Protocol Error on Loopback IP & Aborted Custom Scheme:
MCP Bare URL Reproduction

2. Fixed Behavior — Loopback IPs and Ported Hosts Normalized Properly:
MCP Bare URL Fixed

Why does this happen?

In packages/playwright-core/src/tools/backend/tab.ts:

async checkUrlAndNavigate(url: string): Promise<string> {
  try {
    new URL(url);
  } catch (e) {
    if (url.startsWith('localhost'))
      url = 'http://' + url;
    else
      url = 'https://' + url;
  }
  this.context.checkUrlAllowed(url);
  await this.navigate(url);
  return url;
}
  • WHATWG new URL() does not throw on host:port because host: is treated as a valid scheme name if host begins with an ASCII alpha character ([a-zA-Z]).
  • Loopback IPs begin with numbers (127.0.0.1) so new URL() throws, but the catch branch only checks localhost, falling through to https:// for all IPv4/IPv6 loopback addresses.
Expected behavior
  1. URLs without an explicit scheme (^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/ or ^(about|data|blob|javascript):) should be normalized.
  2. Local loopback addresses (localhost, 127.0.0.1, 0.0.0.0, [::1]) should default to http://.
  3. Other bare hosts (e.g. example.com:8080, playwright.dev) should default to https://.
主要言語
TypeScript
スター
99.1k
フォーク
6.8k
平均マージ
15時間 58分
マージ済み PR(30日)
302

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/playwright のほかの issue

microsoft/playwright の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。