Editor: Prevent adding javascript: and data: URLs through the inline link dialog.

Merge of [41393] to the 3.7 branch.

Built from https://develop.svn.wordpress.org/branches/3.7@41411


git-svn-id: http://core.svn.wordpress.org/branches/3.7@41244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2017-09-19 10:20:44 +00:00
parent fe080e84db
commit 86b3a35dd7
2 changed files with 16 additions and 2 deletions

View File

@ -164,6 +164,13 @@ var wpLink;
attrs = wpLink.getAttrs();
var parser = document.createElement( 'a' );
parser.href = attrs.href;
if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
attrs.href = '';
}
// If there's no href, return.
if ( ! attrs.href || attrs.href == 'http://' )
return;
@ -174,7 +181,7 @@ var wpLink;
if ( attrs.title )
html += ' title="' + attrs.title + '"';
if ( attrs.target )
html += ' target="' + attrs.target + '"';
html += ' rel="noopener" target="' + attrs.target + '"';
html += '>';
@ -221,6 +228,13 @@ var wpLink;
tinyMCEPopup.restoreSelection();
e = ed.dom.getParent(ed.selection.getNode(), 'A');
var parser = document.createElement( 'a' );
parser.href = attrs.href;
if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
attrs.href = '';
}
// If the values are empty, unlink and return
if ( ! attrs.href || attrs.href == 'http://' ) {
if ( e ) {

File diff suppressed because one or more lines are too long