doujingjiao0015 2011-06-29 13:00 采纳率: 0%
浏览 57
已采纳

Zend Framework的自动变量escaper

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)
  • 写回答

2条回答 默认 最新

  • duanji5746 2011-07-04 13:26
    关注

    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 :)

    class Automatic_Escaper extends Zend_Controller_Plugin_Abstract{
       public function postDispatch(Zend_Controller_Request_Abstract $request)
        {
            $response = $this->getResponse();
            $htmlpurifier = Zend_Registry::get('purifier');
            $safe = $htmlpurifier->purify($response);
            return $this->setResponse($safe);
        }
    }
    

    I hope I explained my idea regardless of the status the sample above .

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。