php - laravel 4 - 清理 Input::get() (e() vs HTML::laravel 4 中的实体)

标签 php laravel xss laravel-4 sanitization

我在网上的某处读到,在 blade 模板引擎中,{{ }} 会自动清理输出。

但是,如果我想从 Controller echo 一个经过清理的Input::get 怎么办。最好的方法是什么(e() 只是一个 htmlentitiesHTML::entities 或其他东西)?

最佳答案

I have read somewhere on the web that in the blade template engine, the {{ }} automatically sanitize output.

这是不正确的。您需要使用三 (3) 个大括号来清理输出 {{{ }}}

But, what if I want to echo a sanitized Input::get from the controller.

你不应该从你的 Controller 中输出——你应该从 View 中输出

What is the best way to do it (e() which is just an htmlentities or HTML::entities or something else)?

是的 - e() 是 Laravel 4 中最好的实现方式。

在后端,{{{ }}} 所做的一切实际上都变成了 {{ e() }} 的等价物

编辑:在 Laravel 5 中,{{ }}{{{ }}} 现在都会清理输出。如果你需要在 Laravel 5 中有未处理的输出——你可以使用 {!! !!

关于php - laravel 4 - 清理 Input::get() (e() vs HTML::laravel 4 中的实体),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18534158/

相关文章:

php - 有没有办法在通过 AWS Kinesis Firehose 插入时手动设置 ElasticSearch 文档 ID?

php - 在 php 中通过 twilio 发送短信

php - 在 laravel 的关系表中保存数据时出错

html - 在不受信任的文本中安全地呈现超链接

javascript - 为什么这个内联 javascript 没有被内容安全策略阻止?

php - 将 JSON 数组返回给 ajax

javascript - 在登录表单发布到 php 并由 php 验证登录详细信息后加载 div

LARAVEL 从多个表中获取重复行

Laravel:重定向到另一个需要 POST 变量的 Controller

javascript - 阻止脚本更改 document.location.href?