Make WordPress Core

Changeset 41402 for branches/4.6


Ignore:
Timestamp:
09/19/2017 10:14:53 AM (8 years ago)
Author:
ocean90
Message:

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

Merge of [41393] to the 4.6 branch.

Location:
branches/4.6
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

  • branches/4.6/src/wp-includes/js/tinymce/plugins/wplink/plugin.js

    r38159 r41402  
    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            );
     
    249249                text = inputInstance.getLinkText();
    250250                editor.focus();
     251
     252                var parser = document.createElement( 'a' );
     253                parser.href = href;
     254
     255                if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
     256                    href = '';
     257                }
    251258
    252259                if ( ! href ) {
  • branches/4.6/src/wp-includes/js/wplink.js

    r38126 r41402  
    317317
    318318            if ( attrs.target ) {
    319                 html += ' target="' + attrs.target + '"';
     319                html += ' rel="noopener" target="' + attrs.target + '"';
    320320            }
    321321
     
    341341            attrs = wpLink.getAttrs();
    342342            text = inputs.text.val();
     343
     344            var parser = document.createElement( 'a' );
     345            parser.href = attrs.href;
     346
     347            if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
     348                attrs.href = '';
     349            }
    343350
    344351            // If there's no href, return.
     
    397404                editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
    398405                editor.windowManager.wplinkBookmark = null;
     406            }
     407
     408            var parser = document.createElement( 'a' );
     409            parser.href = attrs.href;
     410
     411            if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
     412                attrs.href = '';
    399413            }
    400414
Note: See TracChangeset for help on using the changeset viewer.