php - 如何在 Laravel5.8 中以表单形式防止 Summernote 中的跨站脚本
问题描述
我已经使用该strip_tags
方法为其他输入法编写了脚本,但它不适用于 Summernote。
我可以使用script_tags
或任何其他方法防止跨站点脚本吗?
我已经尝试过使用该strip_tags
方法,但没有奏效。
$a['description'] = strip_tags($data['description']); //In the Controller
<textarea id='summernote' name="description">//In the form
我希望将代码保存在数据库中,而无需仅使用脚本标签。
解决方案
注意:即使没有脚本标签,您仍然可以引入跨站点脚本漏洞。例如,将其从 html 页面复制并粘贴到 summernote。将鼠标悬停在按钮上将使用户导航到指定页面,没有脚本标签。
<button style="h1" onmouseover='window.location = "http://www.google.com";'>
Totally not malicious. Nothing bad will happen if you just mouseover this text.
</button>
推荐阅读
- c++ - 错误 C2679:二进制“<<”:未找到采用“std::string_view”类型右侧操作数的运算符(或没有可接受的转换)
- woocommerce - WooCommerce 复合产品插件以数量添加到购物车挂钩
- python-3.x - 在openpyxl的优化模式下读写同一个excel
- ubuntu - Fedora 找不到 libSDL2main.so(也不需要它):我可以为 Fedora 和 Ubuntu 使用一个 Makefile 吗?
- php - 在使用具有不同外键的 laravel 时如何删除
- java - 如何从 api 获取数据,然后如果发生变化(使用 firebase)向我的设备发送推送通知?
- java - 我得到一个 nullPointerException 从某些方法调用一个函数,而不是从其他方法
- knex.js - 如何通过 knex.js 选择 json mssql?
- c# - 升级到 .Net Framework 4.8 后,ClickOnce 部署变得流氓
- javascript - 使用不透明类型对 Typescript 记录进行索引