使用 jquery 取消转义数据
所以,我有这样的数据:
"recipient's name"
在服务器上编码为:
recipient's name
然后,我尝试用此文本动态更新 div。
$(this).html("recipient's")
但我将recipient's
名称作为 div 的内容。我本以为 text() 会按字面输出文本,而 html() 会转换特殊字符。
我怎样才能真正获得其中的“收件人姓名”文本? (由于 XSS 注入,我无法在服务器端解码字符串)
So, I have data like:
"recipient's name"
That was encoded on the server as:
recipient's name
Then, I try to dynamically update a div with this text.
$(this).html("recipient's")
But I get recipient's
name as content of the div. I would have thought that text() would have outputted the text literally, whereas html() would have converted special characters.
How can I actually get the text "recipient's name" in there? (I cannot decode the string server-side because of XSS injection)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
肯定还有其他事情发生,我在 jsfiddle.net 上尝试过,在 Firefox 3.6 下工作正常.x 和 Chrome 9.0。
(单击上面的链接并按“运行”查看其运行情况)
There must be something else going on, I tried this on jsfiddle.net and it worked fine under Firefox 3.6.x and Chrome 9.0.
(click on the link above and press 'run' to see it in action)