Make WordPress Core

Changeset 41403 for branches/4.5


Ignore:
Timestamp:
09/19/2017 10:15:01 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.5 branch.

Location:
branches/4.5
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.5

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

    r37454 r41403  
    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            );
     
    217217                text = inputInstance.getLinkText();
    218218                editor.focus();
     219
     220                var parser = document.createElement( 'a' );
     221                parser.href = href;
     222
     223                if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
     224                    href = '';
     225                }
    219226
    220227                if ( ! href ) {
  • branches/4.5/src/wp-includes/js/wplink.js

    r37154 r41403  
    314314
    315315            if ( attrs.target ) {
    316                 html += ' target="' + attrs.target + '"';
     316                html += ' rel="noopener" target="' + attrs.target + '"';
    317317            }
    318318
     
    338338            attrs = wpLink.getAttrs();
    339339            text = inputs.text.val();
     340
     341            var parser = document.createElement( 'a' );
     342            parser.href = attrs.href;
     343
     344            if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
     345                attrs.href = '';
     346            }
    340347
    341348            // If there's no href, return.
     
    394401                editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
    395402                editor.windowManager.wplinkBookmark = null;
     403            }
     404
     405            var parser = document.createElement( 'a' );
     406            parser.href = attrs.href;
     407
     408            if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
     409                attrs.href = '';
    396410            }
    397411
Note: See TracChangeset for help on using the changeset viewer.