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

Merge of [41393] to the 4.8 branch.

Built from https://develop.svn.wordpress.org/branches/4.8@41400


git-svn-id: http://core.svn.wordpress.org/branches/4.8@41233 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2017-09-19 10:15:32 +00:00
parent a905eb3690
commit 1647b11bf4
6 changed files with 26 additions and 5 deletions

View File

@ -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>'
);
},
@ -249,6 +249,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

View File

@ -312,7 +312,7 @@ var wpLink;
var html = '<a href="' + attrs.href + '"';
if ( attrs.target ) {
html += ' target="' + attrs.target + '"';
html += ' rel="noopener" target="' + attrs.target + '"';
}
return html + '>';
@ -337,6 +337,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;
@ -390,6 +397,13 @@ var wpLink;
var attrs = wpLink.getAttrs(),
$link, text, hasText, $mceCaret;
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();

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8.2-alpha-41396';
$wp_version = '4.8.2-alpha-41400';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.