From e804f8f55a11d095ba3e2be33a40cf2e89fceb0d Mon Sep 17 00:00:00 2001 From: konradoboza Date: Wed, 8 Apr 2020 09:17:53 +0200 Subject: [PATCH 1/2] EZP-31539: Link Validation error in Richtext Editor --- .../public/js/scripts/fieldType/base/base-rich-text.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js b/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js index dbe15db350..8887f55cc8 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js @@ -398,11 +398,10 @@ const links = container.querySelectorAll('a'); const anchorPrefix = '#'; const protocolPrefix = 'http://'; - const restrictedKeywords = ['ezcontent', 'ezlocation']; links.forEach((link) => { const href = link.getAttribute('href'); - const protocolPattern = /^https?:\/\//i; + const schemaPattern = /^[a-z0-9]+:\/\//i; const protocolHref = protocolPrefix.concat(href); if (!href) { @@ -413,11 +412,7 @@ return; } - if (protocolPattern.test(href)) { - return; - } - - if (restrictedKeywords.some((keyword) => href.includes(keyword))) { + if (schemaPattern.test(href)) { return; } From da24931d5019fadbbe76353815bc05c75635c534 Mon Sep 17 00:00:00 2001 From: konradoboza Date: Wed, 8 Apr 2020 13:41:52 +0200 Subject: [PATCH 2/2] handled non-essential backslashes for cases like mailto:foo@bar.pl --- .../public/js/scripts/fieldType/base/base-rich-text.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js b/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js index 8887f55cc8..1784384262 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js @@ -401,7 +401,7 @@ links.forEach((link) => { const href = link.getAttribute('href'); - const schemaPattern = /^[a-z0-9]+:\/\//i; + const schemaPattern = /^[a-z0-9]+:\/?\/?/i; const protocolHref = protocolPrefix.concat(href); if (!href) {