File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 renderHtml : function ( ) {
55 return (
66 '<div id="' + this . _id + '" class="wp-link-preview">' +
7- '<a href="' + this . url + '" target="_blank" tabindex="-1">' + this . url + '</a>' +
7+ '<a href="' + this . url + '" target="_blank" rel="noopener" tabindex="-1">' + this . url + '</a>' +
88 '</div>'
99 ) ;
1010 } ,
Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ var wpLink;
278278 var html = '<a href="' + attrs . href + '"' ;
279279
280280 if ( attrs . target ) {
281- html += ' target="' + attrs . target + '"' ;
281+ html += ' rel="noopener" target="' + attrs . target + '"' ;
282282 }
283283
284284 return html + '>' ;
@@ -303,6 +303,13 @@ var wpLink;
303303 attrs = wpLink . getAttrs ( ) ;
304304 text = inputs . text . val ( ) ;
305305
306+ var parser = document . createElement ( 'a' ) ;
307+ parser . href = attrs . href ;
308+
309+ if ( 'javascript:' === parser . protocol || 'data:' === parser . protocol ) { // jshint ignore:line
310+ attrs . href = '' ;
311+ }
312+
306313 // If there's no href, return.
307314 if ( ! attrs . href ) {
308315 return ;
@@ -359,6 +366,13 @@ var wpLink;
359366 editor . selection . moveToBookmark ( editor . windowManager . bookmark ) ;
360367 }
361368
369+ var parser = document . createElement ( 'a' ) ;
370+ parser . href = attrs . href ;
371+
372+ if ( 'javascript:' === parser . protocol || 'data:' === parser . protocol ) { // jshint ignore:line
373+ attrs . href = '' ;
374+ }
375+
362376 if ( ! attrs . href ) {
363377 editor . execCommand ( 'unlink' ) ;
364378 return ;
You can’t perform that action at this time.
0 commit comments