Cakephp 视图中的安全和清理

发布于 2024-11-27 05:37:58 字数 109 浏览 6 评论 0原文

我有一堆数据从控制器传递到视图。有没有一种快速的方法来获取从控制器传递的所有数据,例如在 AppController beforeRender 中,并对这些数据执行 sanitize->html ?

I have a bunch of data getting passed from controllers to views. Is there a quick way to grab all the data being passed from the controllers, like in AppController beforeRender and do a sanitize->html on that data?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

此岸叶落 2024-12-04 05:37:58

快速方法:模型中的 App::import('Sanitize'); 并清理 beforeSave 中的所有内容

Cake Cookbook 建议采用不同的方法:

为了针对 XSS 进行清理,通常最好将原始 HTML 保存在数据库中而不进行修改,并在输出/显示时进行清理。

Quick way: App::import('Sanitize'); in the model and sanitize everything in beforeSave

Cake cookbook advises a different way though:

For sanitization against XSS its generally better to save raw HTML in database without modification and sanitize at the time of output/display.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文