From a10c8691fdf76117e2eefb3cbdf1dc796aa18e4d Mon Sep 17 00:00:00 2001 From: azaozz Date: Fri, 21 Nov 2008 19:36:57 +0000 Subject: [PATCH] Improve filtering of HTML entities from translated strings used in js, see #8254 git-svn-id: http://svn.automattic.com/wordpress/trunk@9836 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-header.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index e3662e2729..2b6aa14f81 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -30,17 +30,21 @@ wp_admin_css( 'css/ie' ); addLoadEvent = function(func) {if (typeof jQuery != "undefined") jQuery(document).ready(func); else if (typeof wpOnload!='function'){wpOnload=func;} else {var oldonload=wpOnload; wpOnload=function(){oldonload();func();}}}; function convertEntities(o) { - var p = document.createElement('p'); - var c = function(s) { p.innerHTML = s; return p.innerHTML; } + var c = function(s) { + if (/&[^;]+;/.test(s)) { + var e = document.createElement("div"); + e.innerHTML = s; + return !e.firstChild ? s : e.firstChild.nodeValue; + } + return s; + } - if ( typeof o === 'object' ) + if ( typeof o === 'object' ) { for (var v in o) o[v] = c(o[v]); - - else if ( typeof o === 'string' ) + return o; + } else if ( typeof o === 'string' ) return c(o); - - p = null; }; //]]>