首页 > 解决方案 > 如何在 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

我希望将代码保存在数据库中,而无需仅使用脚本标签。

标签: phplaravel-5eloquentcontrollerxss

解决方案


注意:即使没有脚本标签,您仍然可以引入跨站点脚本漏洞。例如,将其从 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>

推荐阅读