Skip to content

65417 Editor: Recognize uppercase URL schemes in link validation. - #12103

Open
nimesh-xecurify wants to merge 5 commits into
WordPress:trunkfrom
nimesh-xecurify:65417-editor-js-fix
Open

65417 Editor: Recognize uppercase URL schemes in link validation.#12103
nimesh-xecurify wants to merge 5 commits into
WordPress:trunkfrom
nimesh-xecurify:65417-editor-js-fix

Conversation

@nimesh-xecurify

Copy link
Copy Markdown

Updates the regex used in the link dialog to support schemes with uppercase letters. This prevents the editor from prepending http:// to URLs like HTTPS:// or Http://, which are commonly produced by mobile keyboards.

Includes new QUnit tests to verify correct handling of uppercase, mixed-case, fragment, and root-relative URLs.

Trac ticket: https://core.trac.wordpress.org/ticket/65417

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Sonnet 4.6

Updates the regex used in the link dialog to support schemes with uppercase letters. This prevents the editor from prepending `http://` to URLs like `HTTPS://` or `Http://`, which are commonly produced by mobile keyboards.

Includes new QUnit tests to verify correct handling of uppercase, mixed-case, fragment, and root-relative URLs.
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props nimeshatxecurify, wildworks, irozum, nazmulasif.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copilot AI review requested due to automatic review settings July 28, 2026 07:20

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.

Pull request overview

This PR updates the link-correction logic used by the editor/link dialog so that URLs with uppercase or mixed-case schemes (e.g. HTTPS://, Http://) are recognized as already having a scheme and are not modified by automatically prepending http://. It also adds QUnit coverage around the updated behavior.

Changes:

  • Expand the “has a scheme” regex in both the core link dialog code and the TinyMCE wplink plugin to recognize uppercase scheme letters.
  • Add new QUnit tests covering lowercase, uppercase, mixed-case schemes, plus fragment and root-relative URLs.
  • Load the wplink script and provide minimal fixture/L10n setup for the new QUnit tests.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/qunit/wp-includes/js/wplink.js Adds QUnit tests for wpLink.correctURL() handling of schemes/fragments/root-relative URLs.
tests/qunit/index.html Loads wplink.js in the QUnit runner and adds a minimal fixture input + wpLinkL10n stub.
src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js Updates scheme-detection regex to accept uppercase letters in TinyMCE’s wplink flow.
src/js/_enqueues/lib/link.js Updates scheme-detection regex to accept uppercase letters in wpLink.correctURL().

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

Comment thread src/js/_enqueues/lib/link.js Outdated
Copilot AI review requested due to automatic review settings July 30, 2026 06:15
Extends the scheme-detection regex beyond letters to also allow digits,
`+` and `-` after the first letter, so URLs such as `chrome-extension://`
and `web+demo://` are recognized as already having a scheme.

The `.` allowed by RFC 3986 is deliberately excluded so that a bare host
and port such as `example.com:8080` is still corrected to
`http://example.com:8080` rather than being read as a scheme.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

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.

Pull request overview

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

Copilot AI review requested due to automatic review settings July 30, 2026 06:20

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.

Pull request overview

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

@nazmulasif

Copy link
Copy Markdown

Test Report
Patch tested: #12103

Environment

  • WordPress: 7.1-beta4-20260730.062011
  • Subdirectory: No
  • PHP: 8.5.8 (cli)
  • Server: PHP.wasm (Emscripten 4.0.19 wasm32)
  • Database: WP_MySQL_On_SQLite (Server: 8.0.38 / Client: 3.51.0)
  • Browser: Chrome 150.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.5
  • MU Plugins: None activated
  • Plugins:
    • Classic Editor 1.7.0
    • Test Reports 1.3.0

Steps taken

  1. Opened WordPress Playground PR preview for PR 65417 Editor: Recognize uppercase URL schemes in link validation. #12103 (Trac #65417) with the Classic Editor active.
  2. Navigated to Posts > Add New and created a Classic Editor instance.
  3. Added sample text, selected it, and clicked the Insert/Edit Link icon in the toolbar.
  4. Clicked the Link Options gear icon (⚙️) to open the full wpLink modal dialog.
  5. In the URL field, entered a URL with an uppercase protocol (https://example.com/ and http://example.com/).
  6. Moved focus away from the input field (triggered blur event / wpLink.correctURL()) and submitted the link dialog.
  7. Also verified directly in the browser developer console by targeting the modal input DOM element:
    jQuery('#wp-link-url').val('https://example.com/');
    wpLink.correctURL();
    console.log(jQuery('#wp-link-url').val());
    // Result: "https://example.com/"
  8. Confirmed that the URL protocol is preserved as entered without prepending http://.
  • ✅ Patch is solving the problem

Expected result
URLs containing uppercase or mixed-case protocols (e.g. https://example.com/ or http://example.com/) should be recognized as already having a scheme and should NOT have http:// prepended to create broken double-protocol URLs (http://https/://example.com).

Additional Notes
Tested and verified pull request #12103 for Trac #65417.

Screenshots/Screencast with results
Attached: showing manual test verification in post editor

Support Content
Trac Ticket: https://core.trac.wordpress.org/ticket/65417

WordPress-Playground.mp4

irozum

This comment was marked as low quality.

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.

5 participants