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

Merge of [41393] to the 3.9 branch.

Built from https://develop.svn.wordpress.org/branches/3.9@41409


git-svn-id: http://core.svn.wordpress.org/branches/3.9@41242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2017-09-19 10:20:24 +00:00
parent 66aaaa6aa8
commit 435ca07747
2 changed files with 16 additions and 2 deletions

View File

@ -179,6 +179,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;
@ -192,7 +199,7 @@ var wpLink;
}
if ( attrs.target ) {
html += ' target="' + attrs.target + '"';
html += ' rel="noopener" target="' + attrs.target + '"';
}
html += '>';
@ -244,6 +251,13 @@ var wpLink;
link = editor.dom.getParent( editor.selection.getNode(), 'a[href]' );
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://' ) {
editor.execCommand( 'unlink' );

File diff suppressed because one or more lines are too long