Improve filtering of HTML entities from translated strings used in js, see #8254

git-svn-id: https://develop.svn.wordpress.org/trunk@9836 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2008-11-21 19:36:57 +00:00
parent 8969d49dbe
commit 02be72d69a
1 changed files with 11 additions and 7 deletions

View File

@ -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;
};
//]]>
</script>