javascript - Escape HTML tags. Any isue possible with charset encoding? -
i have function escape html tags, able insert text html. similar : can escape html special chars in javascript?
i know javascript use unicode internally, html pages may encoded in different charsets utf-8 or iso8859-1, etc..
my question is: there issue simple conversion? or should take consideration page charset?
if yes, idea of way handle that?
ps: example, equivalente php function (http://php.net/manual/en/function.htmlspecialchars.php) has parameter select charset.
no, javascript lives in unicode world encoding issues invisible it. escapehtml
in linked question fine.
the place can think of javascript gets see bytes data:
urls (typically hidden beneath base64). this:
var markup = '<p>hello, '+escapehtml(user_supplied_data); var url = 'data:text/html;base64,'+btoa(markup); iframe.src = url;
is in principle bad thing. although don't know of browsers guess utf-7 in situation, charset=...
parameter should supplied ensure browser uses appropriate encoding data. (btoa
uses iso-8859-1, it's worth.)
Comments
Post a Comment