Zend Framework 的自动变量转义器
您能为 Zend Framework 1.x 推荐任何好的自动视图变量转义解决方案吗?
到目前为止我已经尝试过:
- ZF2 实现;看起来它没有转义变量语法,如下所示:
$this->var->object()->string
- gnix-view,非常好,但是有一个令人讨厌的递归错误
- 基于
视图流
的自定义解决方案,类似于Rob Allen 的转义符,但是用正则表达式解析语法总是失败 - Twig(没有对视图助手和布局的良好支持)
Can you recommend any good solution for automatic view variable escaping for Zend Framework 1.x?
I have tried so far:
- ZF2 implementation; looks like it does not escape variables syntax like this:
$this->var->object()->string
- gnix-view, very nice, but has a nasty recursion bug
- custom solutions based on
view streams
, similar to Rob Allen's escaper, but parsing syntax with regex always fails - Twig (no good support for view helpers and layout)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我的解决方案
您所需要做的就是将其设置为引导程序中的视图。
Here is my solution
All you need to do is to set it as your view in bootstrap.
如果我想制作一个自动转义器,我会创建一个在
postDispatch
中运行的 ZF 插件:postDispatch() 在调度程序调度操作后调用。此回调允许代理或过滤器行为。通过更改请求并重置其分派标志(通过 Zend_Controller_Request_Abstract::setDispatched(false)),可以为分派指定新的操作。 source
mybe 使用 htmlprifier 将是一项明智的工作:)
我希望我解释了我的想法,无论状态上述示例。
if i would think to make an automatic escaper i would create a ZF plugin that run in
postDispatch
:postDispatch() is called after an action is dispatched by the dispatcher. This callback allows for proxy or filter behavior. By altering the request and resetting its dispatched flag (via Zend_Controller_Request_Abstract::setDispatched(false)), a new action may be specified for dispatching. source
mybe some use of htmlprifier would be a smart job :)
I hope I explained my idea regardless of the status the sample above .