【问题标题】:CakePHP app black holes routed form requestsCakePHP 应用程序黑洞路由表单请求
【发布时间】:2013-05-20 15:07:19
【问题描述】:

我有一个带有以下路线的 CakePHP 2.3 设置:

Router::connect('/contact', array('controller' => 'old_layout', 'action' => 'contact'));

在我的 AppController 中,我定义了

public $components = array(
    'Security'...
);

在 OldLayoutController 中,在我定义的 beforeFilter() 函数中:

$this->Security->allowedControllers = array('OldLayout');

在 old_layout/contact 视图中,我使用 Form->create() 和 end() 函数以及常规 Form::input()... 命令生成表单。

当我在 /contact 提交表单时,我收到以下消息:

The request has been black-holed
Error: The requested address '/[domain].com/contact' was not found on this server.

问题是,我在另一个完美运行的控制器中为另一个表单做同样的事情。

【问题讨论】:

  • 可能很明显,但在 OldLayout 控制器上是否定义了联系操作?
  • 当然,它完全实现、单元测试和工作。我在事后添加了这个安全的东西。这提醒了我,我的单元测试(考虑到这种安全性)工作得很好。
  • 我已将其范围缩小到令牌和 SecurityComponent::_validatePost() 中生成的检查不匹配的事实。这很奇怪,因为即使修改了表单(使用 $this->Form->unlockField()...)和 SecurityComponent::unlockedFields() 列表以忽略正确的表单元素集,它仍然会生成一个不同的 $check 令牌。
  • 经过多次调试,我想通了。这完全是由于错误生成的错误“重置”按钮造成的。
  • @Derek 您可能想回答您自己的问题并将该答案标记为“解决方案”,以便我们知道它已解决:) 浪费了我宝贵的几分钟时间:D

标签: php security cakephp cakephp-2.0


【解决方案1】:

经过多次调试,我想通了。这完全是由于错误生成的错误“重置”按钮造成的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-30
    相关资源
    最近更新 更多