mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-13 06:07:23 +01:00
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:
parent
66aaaa6aa8
commit
435ca07747
@ -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' );
|
||||
|
2
wp-includes/js/wplink.min.js
vendored
2
wp-includes/js/wplink.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user