Skip to content

Commit

Permalink
Fixes zendframework#440 - Zend_Controller_Dispatcher_Abstract::_forma…
Browse files Browse the repository at this point in the history
…tName() inconsistent with name handling
  • Loading branch information
froschdesign authored and Dimitris Giotas committed Jun 17, 2016
1 parent 96fb075 commit f5e0810
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
6 changes: 5 additions & 1 deletion library/Zend/Controller/Action/Helper/ViewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,11 @@ protected function _translateSpec(array $vars = array())
$request = $this->getRequest();
$dispatcher = $this->getFrontController()->getDispatcher();
$module = $dispatcher->formatModuleName($request->getModuleName());
$controller = $request->getControllerName();
$controller = substr(
$dispatcher->formatControllerName($request->getControllerName()),
0,
-10
);
$action = $dispatcher->formatActionName($request->getActionName());

$params = compact('module', 'controller', 'action');
Expand Down
34 changes: 34 additions & 0 deletions tests/Zend/Controller/Action/Helper/ViewRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,40 @@ public function providerViewScriptNameDoesNotIncludeDisallowedCharacters()
);
}

/**
* @group GH-440
* @dataProvider providerControllerNameDoesNotIncludeDisallowedCharacters
*/
public function testControllerNameDoesNotIncludeDisallowedCharacters($controllerName)
{
$this->request->setControllerName($controllerName)
->setActionName('index');

$this->helper->setActionController(
new Bar_IndexController(
$this->request, $this->response, array()
)
);

$this->assertEquals(
'index/index.phtml', $this->helper->getViewScript()
);
}

/**
* Data provider for testControllerNameDoesNotIncludeDisallowedCharacters
* @group GH-440
* @return array
*/
public function providerControllerNameDoesNotIncludeDisallowedCharacters()
{
return array(
array('!index'),
array('@index'),
array('-index'),
);
}

protected function _normalizePath($path)
{
return str_replace(array('/', '\\'), '/', $path);
Expand Down

0 comments on commit f5e0810

Please sign in to comment.