I need to block Html Tags of a h:inputTextarea. The content of this textarea will be shown in an outputText with escape setted to false. It's setted to false cause i'm allowing to show links <a href...>.

我需要阻止h:inputTextarea的Html标签。此textarea的内容将显示在outputText中,其中escape设置为false。它设置为false,因为我允许显示链接。

When I click on save, it verifies the written words to check if is there a link, and if it is, we save on database with <a href...>

当我点击保存时,它会验证书面文字以检查是否有链接,如果有,我们将使用保存在数据库中

If this that i'm doing above is the wrong way to do it, let me know, but don't forget to try to help me out blocking html tags. If I'm wrong on how to do it, i'll do it later, but I need to fix this like i said it now :(

如果我上面这样做是错误的方法,请告诉我,但不要忘记尝试帮助我阻止html标签。如果我错误的怎么做,我会在以后再做,但我需要解决这个,就像我现在说的那样:(

ty

1 个解决方案

#1


0

You should use some other markup language like markdown instead of HTML to prevent XSS. If you allow the a-Tag, user could still write stuff like:

您应该使用其他标记语言,如markdown而不是HTML来阻止XSS。如果您允许使用a-Tag,用户仍然可以编写如下内容:

<a href="javascript:doSomethingEvil()">foo</a>

And if you go on and try to find and filter stuff like that too, take a look at these nice examples: http://ha.ckers.org/xss.html

如果你继续尝试查找和过滤类似的东西,请看看这些漂亮的例子:http://ha.ckers.org/xss.html

EDIT: If is really the only tag, you want to allow and you just want to have clickable links, why don't you try to recognize URLs in text instead of forcing the user to write HTML? Check out this SO question.

编辑:如果真的是唯一的标签,你想允许,你只想拥有可点击的链接,为什么你不尝试识别文本中的URL而不是强迫用户编写HTML?看看这个问题。

更多相关文章

  1. 在HTML标签中显示很长一段文字,显示两行,多余部分显示省略号,这个怎
  2. HTML标签的默认样式
  3. 如何将带有图形链接的列表转换为内联列表?
  4. HTML5的重点知识小结——整体布局(浮动布局、选择标签)
  5. 49、html基础认识&常用标签(1)
  6. 180225-第一百零七天【html链接,头部】
  7. HTML语言中img标签的alt属性和title属性的作用与区别
  8. 【HTML】让标签文本自动换行
  9. js去除字符串中所有html标签及 符号

随机推荐

  1. json解析天气预报
  2. Android单元测试Unable to find instrume
  3. Android通过Intent.ACTION_CLOSE_SYSTEM_
  4. ubuntu下安装android ndk
  5. Android adb: The connection to adb is
  6. 浅析Android中的消息机制
  7. android实现软件指导页
  8. Android判断真机和模拟器
  9. Android 软键盘弹出时,把整个界面往上挤
  10. android SQLiteDatabase 错误 database d