FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.10] gh-143930: Reject leading dashes in webbrowser URLs (GH-143931) by tomcruiseqi · Pull Request #146359 · python/cpython · GitHub

/ cpython Public

[3.10] gh-143930: Reject leading dashes in webbrowser URLs (GH-143931) - #146359

Merged
ambv merged 1 commit into
python:3.10from
tomcruiseqi:backport-82a24a4-3.10
Mar 24, 2026
Merged

[3.10] gh-143930: Reject leading dashes in webbrowser URLs (GH-143931)#146359
ambv merged 1 commit into
python:3.10from
tomcruiseqi:backport-82a24a4-3.10

Conversation

tomcruiseqi commented Mar 24, 2026
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

This PR backports a security hardening change to webbrowser to prevent option-injection style issues by rejecting URLs that begin with - (after leading whitespace) before passing them to browser launchers.

Changes:

  • Add BaseBrowser._check_url() to reject leading-dash URLs with a ValueError.
  • Invoke _check_url() from multiple open() implementations that launch browsers.
  • Add a regression test and a Security NEWS blurb.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
Misc/NEWS.d/next/Security/2026-01-16-12-04-49.gh-issue-143930.zYC5x3.rst Documents the security behavior change in webbrowser.open().
Lib/webbrowser.py Introduces URL validation and applies it to several browser controllers.
Lib/test/test_webbrowser.py Adds a test ensuring leading-dash inputs are rejected (currently for GenericBrowser).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Lib/webbrowser.py
Comment thread Lib/webbrowser.py
(cherry picked from commit 82a24a4)

Co-authored-by: Seth Michael Larson <seth@python.org>
tomcruiseqi force-pushed the backport-82a24a4-3.10 branch from 69fd15b to c84b32d Compare March 24, 2026 07:16
tomcruiseqi changed the title [3.10] gh-143930: Reject leading dashes in webbrowser URLs [3.10] gh-143930: Reject leading dashes in webbrowser URLs (GH-143931) Mar 24, 2026
bedevere-app Bot added the type-security A security issue label Mar 24, 2026
ambv merged commit ad4d5ba into python:3.10 Mar 24, 2026
15 checks passed
hroncok pushed a commit to fedora-python/cpython that referenced this pull request Mar 26, 2026
Reject leading dashes in webbrowser URLs (pythonGH-143931) (pythonGH-146359)

Cherry-picked from Python 3.10: ad4d5ba

(cherry picked from commit 82a24a4)

Co-authored-by: Seth Michael Larson <seth@python.org>
hroncok pushed a commit to fedora-python/cpython that referenced this pull request Mar 26, 2026
Reject leading dashes in webbrowser URLs (pythonGH-143931) (pythonGH-146359)

(cherry picked from commit 82a24a4)

Backported from Python 3.10: ad4d5ba

Co-authored-by: Seth Michael Larson <seth@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-security A security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL