mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-14 06:36:47 +01:00
Editor: Prevent adding javascript:
and data:
URLs through the inline link dialog.
Merge of [41393] to the 4.5 branch. Built from https://develop.svn.wordpress.org/branches/4.5@41403 git-svn-id: http://core.svn.wordpress.org/branches/4.5@41236 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
030d6166f9
commit
0d5353afbc
@ -4,7 +4,7 @@
|
||||
renderHtml: function() {
|
||||
return (
|
||||
'<div id="' + this._id + '" class="wp-link-preview">' +
|
||||
'<a href="' + this.url + '" target="_blank" tabindex="-1">' + this.url + '</a>' +
|
||||
'<a href="' + this.url + '" target="_blank" rel="noopener" tabindex="-1">' + this.url + '</a>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
@ -217,6 +217,13 @@
|
||||
text = inputInstance.getLinkText();
|
||||
editor.focus();
|
||||
|
||||
var parser = document.createElement( 'a' );
|
||||
parser.href = href;
|
||||
|
||||
if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
|
||||
href = '';
|
||||
}
|
||||
|
||||
if ( ! href ) {
|
||||
editor.dom.remove( linkNode, true );
|
||||
return;
|
||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -313,7 +313,7 @@ var wpLink;
|
||||
var html = '<a href="' + attrs.href + '"';
|
||||
|
||||
if ( attrs.target ) {
|
||||
html += ' target="' + attrs.target + '"';
|
||||
html += ' rel="noopener" target="' + attrs.target + '"';
|
||||
}
|
||||
|
||||
return html + '>';
|
||||
@ -338,6 +338,13 @@ var wpLink;
|
||||
attrs = wpLink.getAttrs();
|
||||
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 ( ! attrs.href ) {
|
||||
return;
|
||||
@ -395,6 +402,13 @@ var wpLink;
|
||||
editor.windowManager.wplinkBookmark = null;
|
||||
}
|
||||
|
||||
var parser = document.createElement( 'a' );
|
||||
parser.href = attrs.href;
|
||||
|
||||
if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
|
||||
attrs.href = '';
|
||||
}
|
||||
|
||||
if ( ! attrs.href ) {
|
||||
editor.execCommand( 'unlink' );
|
||||
wpLink.close();
|
||||
|
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