From 5433303166b88ea118a5ee2cc730d1cf8d165a6c Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 4 Mar 2015 20:34:35 +0000 Subject: [PATCH] TinyMCE wpView: decode HTML entities before trying to insert view markers. Props iseulde. See #31412. git-svn-id: https://develop.svn.wordpress.org/trunk@31612 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/mce-view.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/js/mce-view.js b/src/wp-includes/js/mce-view.js index f3487d8f50..8082c1a302 100644 --- a/src/wp-includes/js/mce-view.js +++ b/src/wp-includes/js/mce-view.js @@ -28,10 +28,25 @@ window.wp = window.wp || {}; 'use strict'; var views = {}, - instances = {}; + instances = {}, + textarea = document.createElement( 'textarea' ); wp.mce = wp.mce || {}; + /** + * Decode HTML entities in a givin string. + * + * @param {String} html The string to decode. + */ + function decodeHTML( html ) { + textarea.innerHTML = html; + html = textarea.value; + + textarea.innerHTML = textarea.value = ''; + + return html; + } + /** * wp.mce.views * @@ -89,7 +104,7 @@ window.wp = window.wp || {}; * @param {String} content The string to scan. */ setMarkers: function( content ) { - var pieces = [ { content: content } ], + var pieces = [ { content: decodeHTML( content ) } ], self = this, current; @@ -390,7 +405,7 @@ window.wp = window.wp || {}; */ replaceMarkers: function() { this.getMarkers( function( editor, node ) { - if ( $( node ).html() !== this.text ) { + if ( $( node ).text() !== this.text ) { editor.dom.setAttrib( node, 'data-wpview-marker', null ); return; }