Editor: Prevent adding `javascript:` and `data:` URLs through the inline link dialog.
Merge of [41393] to the 4.2 branch. Built from https://develop.svn.wordpress.org/branches/4.2@41406 git-svn-id: http://core.svn.wordpress.org/branches/4.2@41239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a01117bf0d
commit
ecf502b597
|
@ -285,8 +285,16 @@ var wpLink;
|
||||||
attrs = wpLink.getAttrs();
|
attrs = wpLink.getAttrs();
|
||||||
text = inputs.text.val();
|
text = inputs.text.val();
|
||||||
|
|
||||||
|
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 there's no href, return.
|
||||||
if ( ! attrs.href ) {
|
if ( ! attrs.href ) {
|
||||||
|
wpLink.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +302,7 @@ var wpLink;
|
||||||
html = '<a href="' + attrs.href + '"';
|
html = '<a href="' + attrs.href + '"';
|
||||||
|
|
||||||
if ( attrs.target ) {
|
if ( attrs.target ) {
|
||||||
html += ' target="' + attrs.target + '"';
|
html += ' rel="noopener" target="' + attrs.target + '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
html += '>';
|
html += '>';
|
||||||
|
@ -348,6 +356,13 @@ var wpLink;
|
||||||
editor.selection.moveToBookmark( editor.windowManager.bookmark );
|
editor.selection.moveToBookmark( editor.windowManager.bookmark );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var parser = document.createElement( 'a' );
|
||||||
|
parser.href = attrs.href;
|
||||||
|
|
||||||
|
if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
|
||||||
|
attrs.href = '';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! attrs.href ) {
|
if ( ! attrs.href ) {
|
||||||
editor.execCommand( 'unlink' );
|
editor.execCommand( 'unlink' );
|
||||||
return;
|
return;
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue