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

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


心有法竹
浏览 227回答 2
2回答

蝴蝶刀刀

注意:即使没有脚本标记,您仍然可以引入跨站点脚本漏洞。例如,将其从 html 页面复制并粘贴到 summernote 中。将鼠标悬停在按钮上将使用户导航到指定的页面,没有脚本标记。<button style="h1" onmouseover='window.location = "http://www.google.com";'>&nbsp; &nbsp; Totally not malicious. Nothing bad will happen if you just mouseover this text.</button>

DIEA

像这样使用“e”函数:$a['description']&nbsp;=&nbsp;e($data['description']);
打开App,查看更多内容
随时随地看视频慕课网APP