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
This commit is contained in:
azaozz 2008-11-21 19:36:57 +00:00
parent 61fb6ea540
commit a10c8691fd

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>