Filter HTML entities when inserting strings with js, includes patch by nbachiyski, fixes #8254

git-svn-id: http://svn.automattic.com/wordpress/trunk@9809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2008-11-20 10:54:59 +00:00
parent 30c3602b92
commit 5785542e00
3 changed files with 26 additions and 34 deletions

View File

@ -28,6 +28,20 @@ wp_admin_css( 'css/ie' );
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
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();}}}; 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; }
if ( typeof o === 'object' )
for (var v in o)
o[v] = c(o[v]);
else if ( typeof o === 'string' )
return c(o);
p = null;
};
//]]> //]]>
</script> </script>
<?php <?php

View File

@ -215,7 +215,7 @@ jQuery(document).ready( function($) {
}); });
var showNotice, adminMenu, columns; var showNotice, adminMenu, columns;
(function($){
// stub for doing better warnings // stub for doing better warnings
showNotice = { showNotice = {
warn : function(text) { warn : function(text) {
@ -229,7 +229,6 @@ showNotice = {
alert(text); alert(text);
} }
}; };
})(jQuery);
(function($){ (function($){
// sidebar admin menu // sidebar admin menu
@ -350,39 +349,17 @@ columns = {
} }
})(jQuery); })(jQuery);
/* /*
(function($) { (function($) {
$.fn.tTips = function() { $.attrEn = function(elem, name, value) {
if ( typeof value === 'string' )
$('body').append('<div id="tTips"><p id="tTips_inside"></p></div>'); value = $('<span>'+value+'</span>').html();
var TT = $('#tTips'); return $.attr(elem, name, value);
this.each(function() {
var el = $(this), txt;
if ( txt = el.attr('title') ) el.attr('tip', txt).removeAttr('title');
else return;
el.find('img').removeAttr('alt');
el.mouseover(function(e) {
txt = el.attr('tip'), o = el.offset();
clearTimeout(TT.sD);
TT.find('p').html(txt);
TT.css({'top': o.top - 43, 'left': o.left - 5});
TT.sD = setTimeout(function(){TT.fadeIn(150);}, 100);
});
el.mouseout(function() {
clearTimeout(TT.sD);
TT.css({display : 'none'});
})
});
} }
}(jQuery)); $.fn.valEn = function(value) {
if ( typeof value === 'string' )
value = $('<span>'+value+'</span>').html();
return $.fn.val.call(this, value);
}
})(jQuery);
*/ */
//jQuery(function(){jQuery('#media-buttons a').tTips();});

View File

@ -51,6 +51,7 @@ class WP_Scripts extends WP_Dependencies {
$eol = ",\n"; $eol = ",\n";
} }
echo "\n\t}\n"; echo "\n\t}\n";
echo "try{convertEntities($object_name);}catch(e){};\n";
echo "/* ]]> */\n"; echo "/* ]]> */\n";
echo "</script>\n"; echo "</script>\n";