From b7108eed7c106ffa0fc7130967d7069cbdd98d2d Mon Sep 17 00:00:00 2001 From: Nimesh Date: Fri, 5 Jun 2026 12:37:28 +0530 Subject: [PATCH 1/2] Editor: Recognize uppercase URL schemes in link validation. 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. --- src/js/_enqueues/lib/link.js | 2 +- .../vendor/tinymce/plugins/wplink/plugin.js | 2 +- tests/qunit/index.html | 4 ++ tests/qunit/wp-includes/js/wplink.js | 68 +++++++++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 tests/qunit/wp-includes/js/wplink.js diff --git a/src/js/_enqueues/lib/link.js b/src/js/_enqueues/lib/link.js index a2500a9069648..a26785929647c 100644 --- a/src/js/_enqueues/lib/link.js +++ b/src/js/_enqueues/lib/link.js @@ -95,7 +95,7 @@ correctURL: function () { var url = inputs.url.val().trim(); - if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) { + if ( url && correctedURL !== url && ! /^(?:[a-zA-Z]+:|#|\?|\.|\/)/.test( url ) ) { inputs.url.val( 'http://' + url ); correctedURL = url; } diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js index 76781894171e8..3f498fb3ee3a0 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js @@ -264,7 +264,7 @@ return; } - if ( ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) && ! emailRegex.test( href ) ) { + if ( ! /^(?:[a-zA-Z]+:|#|\?|\.|\/)/.test( href ) && ! emailRegex.test( href ) ) { href = 'http://' + href; } diff --git a/tests/qunit/index.html b/tests/qunit/index.html index 9fd35f0c1ffc2..0fe52dd83d6a6 100644 --- a/tests/qunit/index.html +++ b/tests/qunit/index.html @@ -76,6 +76,7 @@
+ @@ -87,6 +88,8 @@
+ + @@ -166,6 +169,7 @@ +