Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZEE-3030: Links containing 'ezlocation` or 'ezcontent' keywords break RTE validation on paste #1283

Merged
merged 3 commits into from
Mar 18, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -398,17 +398,31 @@
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 protocolHref = protocolPrefix.concat(href);

if (href && href.indexOf(anchorPrefix) !== 0 && !protocolPattern.test(href)) {
const protocolHref = protocolPrefix.concat(href);
if (!href) {
konradoboza marked this conversation as resolved.
Show resolved Hide resolved
return;
}

if (href.indexOf(anchorPrefix) === 0) {
return;
}

link.setAttribute('href', protocolHref);
link.setAttribute('data-cke-saved-href', protocolHref);
if (protocolPattern.test(href)) {
return;
}

if (restrictedKeywords.some(keyword => href.includes(keyword))) {
konradoboza marked this conversation as resolved.
Show resolved Hide resolved
return;
}

link.setAttribute('href', protocolHref);
link.setAttribute('data-cke-saved-href', protocolHref);
});
}
};
Expand Down