[BUG]: Some JS characters aren't escaped when running the page-ready check

オープン 初心者向け
#316 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@Blizzeq がすでに取り組んでいます。

2026年10月1日 から。

  • #317 @Blizzeq による — オープン

評価

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

調査の方向性

バグは src/choreographer/protocol/devtools_async_helpers.py の 37 行目にあり、URL が JavaScript のテンプレートリテラルに挿入されています。まず、create_and_wait 関数とその周囲の devtools プロトコルヘルパーを調べてください。json.dumps を使用して URL 文字列を適切にエスケープし、また、レスポンス内の exceptionDetails をチェックするように関数を更新してください。提供された再現スクリプトを実行して修正を確認してください。

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

説明

bug P3 size: 1
Description

The page-ready check inserts the URL into a JavaScript template literal without escaping it, at src/choreographer/protocol/devtools_async_helpers.py:37. A backtick in the URL ends the literal, and a ${...} sequence in the URL runs as JavaScript.

Steps to reproduce
  • Run the following code:
import asyncio
import choreographer as choreo
from choreographer.protocol.devtools_async_helpers import create_and_wait

async def main():
    browser = await choreo.Browser(headless=True)
    try:
        # Correct: raises TimeoutError after 5s, because the address never loads
        await create_and_wait(browser, url="http://192.0.2.1:9999", timeout=5.0)
    except TimeoutError:
        print("plain URL: TimeoutError")
    # Wrong: returns after 0.02s, for the same unreachable address
    await create_and_wait(browser, url="http://192.0.2.1:9999/`", timeout=5.0)
    print("URL with a backtick: returned OK")
    await browser.close()

asyncio.run(main())

For the second problem, pass https://www.example.com/${(window.__injected = 42, "")} to create_and_wait, then read window.__injected back from the page. The value is 42.

Notes
  • With this bug:
    • A backtick makes the script raise a SyntaxError. Runtime.evaluate returns that as a normal response, and the race in create_and_wait counts any finished task as a load. So create_and_wait returns a tab for a page that never loaded.
    • A ${...} sequence runs arbitrary JavaScript in the page.
  • A fix is to build the JavaScript string with json.dumps(url) and drop the backticks from the template. json.dumps supplies its own quotes and escapes the contents, so a backtick and a ${ are both inert.
  • create_and_wait should also inspect the response for exceptionDetails instead of counting every finished task as a successful load
  • This was found while working on #295
主要言語
Python
スター
17
フォーク
10
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

plotly/choreographer のほかの issue

plotly/choreographer の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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