Make WordPress Core

Changeset 35341


Ignore:
Timestamp:
10/21/2015 08:37:54 PM (11 years ago)
Author:
azaozz
Message:

TinyMCE:

  • Sanitize and render HTML in captions when showing a gallery preview (wpView).
  • Encode/escape HTML entered in the text field in the wpLink dialog.

Props iseulde, kraftbj, jnylen0, shawarkhan.
Fixes #32616.

Location:
trunk/src/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/mce-view.js

    r35216 r35341  
    733733 */
    734734( function( window, views, media, $ ) {
    735         var base, gallery, av, embed;
     735        var base, gallery, av, embed,
     736                schema, parser, serializer;
     737
     738        function verifyHTML( string ) {
     739                var settings = {};
     740
     741                if ( ! window.tinymce ) {
     742                        return string.replace( /<[^>]+>/g, '' );
     743                }
     744
     745                if ( ! string || ( string.indexOf( '<' ) === -1 && string.indexOf( '>' ) === -1 ) ) {
     746                        return string;
     747                }
     748
     749                schema = schema || new window.tinymce.html.Schema( settings );
     750                parser = parser || new window.tinymce.html.DomParser( settings, schema );
     751                serializer = serializer || new window.tinymce.html.Serializer( settings, schema );
     752
     753                return serializer.serialize( parser.parse( string, { forced_root_block: false } ) );
     754        }
    736755
    737756        base = {
     
    784803
    785804                                self.render( self.template( {
     805                                        verifyHTML: verifyHTML,
    786806                                        attachments: attachments,
    787807                                        columns: attrs.columns ? parseInt( attrs.columns, 10 ) : media.galleryDefaults.columns
  • trunk/src/wp-includes/js/wplink.js

    r33591 r35341  
    383383                        } else {
    384384                                if ( text ) {
    385                                         editor.selection.setNode( editor.dom.create( 'a', attrs, text ) );
     385                                        editor.selection.setNode( editor.dom.create( 'a', attrs, editor.dom.encode( text ) ) );
    386386                                } else {
    387387                                        editor.execCommand( 'mceInsertLink', false, attrs );
  • trunk/src/wp-includes/media-template.php

    r34049 r35341  
    12171217                                                <# if ( attachment.caption ) { #>
    12181218                                                        <dd class="wp-caption-text gallery-caption">
    1219                                                                 {{ attachment.caption }}
     1219                                                                {{{ data.verifyHTML( attachment.caption ) }}}
    12201220                                                        </dd>
    12211221                                                <# } #>
Note: See TracChangeset for help on using the changeset viewer.