Make WordPress Core

Changeset 31612


Ignore:
Timestamp:
03/04/2015 08:34:35 PM (10 years ago)
Author:
azaozz
Message:

TinyMCE wpView: decode HTML entities before trying to insert view markers. Props iseulde. See #31412.

File:
1 edited

Legend:

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

    r31586 r31612  
    2929
    3030    var views = {},
    31         instances = {};
     31        instances = {},
     32        textarea = document.createElement( 'textarea' );
    3233
    3334    wp.mce = wp.mce || {};
     35
     36    /**
     37     * Decode HTML entities in a givin string.
     38     *
     39     * @param {String} html The string to decode.
     40     */
     41    function decodeHTML( html ) {
     42        textarea.innerHTML = html;
     43        html = textarea.value;
     44
     45        textarea.innerHTML = textarea.value = '';
     46
     47        return html;
     48    }
    3449
    3550    /**
     
    90105         */
    91106        setMarkers: function( content ) {
    92             var pieces = [ { content: content } ],
     107            var pieces = [ { content: decodeHTML( content ) } ],
    93108                self = this,
    94109                current;
     
    391406        replaceMarkers: function() {
    392407            this.getMarkers( function( editor, node ) {
    393                 if ( $( node ).html() !== this.text ) {
     408                if ( $( node ).text() !== this.text ) {
    394409                    editor.dom.setAttrib( node, 'data-wpview-marker', null );
    395410                    return;
Note: See TracChangeset for help on using the changeset viewer.