热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

createTextNode对HTML注入和XSS完全安全吗?-IscreateTextNodecompletelysafefromHTMLinjection&XSS?

Imworkingonasinglepagewebapp.ImdoingtherenderingbydirectlycreatingDOMnodes.Inpart

I'm working on a single page webapp. I'm doing the rendering by directly creating DOM nodes. In particular, all user-supplied data is added to the page by creating text nodes with document.createTextNode("user data").

我正在开发一个网页应用。我通过直接创建DOM节点来进行渲染。特别是,所有用户提供的数据都通过使用文档创建文本节点添加到页面中。createTextNode(“用户数据”)。

Does this approach avoid any possibility of HTML injection, cross site scripting (XSS), and all the other evil things users could do?

这种方法是否可以避免HTML注入、跨站点脚本(XSS)以及用户可以做的所有其他坏事?

1 个解决方案

#1


9  

It creates a plain text node, so yes, as far as it goes.

它创建一个纯文本节点,因此,就目前而言,是这样的。

It is possible to create an XSS problem by using an unsafe method to get the data from whatever channel it is being input into to createTextNode though.

通过使用不安全的方法从输入到createTextNode的任何通道获取数据,可以创建XSS问题。

e.g. The following would be unsafe:

例:下列情况是不安全的:

document.createTextNode('');

… but the danger is from the PHP echo, not the Javascript createTextNode.

但是危险来自PHP echo,而不是Javascript createTextNode。


推荐阅读
author-avatar
江湖小子的美好生活_498_416
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有