Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 40dd702

Browse files
committed
Fixes zendframework#440 - Zend_Controller_Dispatcher_Abstract::_formatName() inconsistent with name handling
1 parent 56d2679 commit 40dd702

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

library/Zend/Controller/Action/Helper/ViewRenderer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,11 @@ protected function _translateSpec(array $vars = array())
842842
$request = $this->getRequest();
843843
$dispatcher = $this->getFrontController()->getDispatcher();
844844
$module = $dispatcher->formatModuleName($request->getModuleName());
845-
$controller = $request->getControllerName();
845+
$controller = substr(
846+
$dispatcher->formatControllerName($request->getControllerName()),
847+
0,
848+
-10
849+
);
846850
$action = $dispatcher->formatActionName($request->getActionName());
847851

848852
$params = compact('module', 'controller', 'action');

tests/Zend/Controller/Action/Helper/ViewRendererTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,40 @@ public function providerViewScriptNameDoesNotIncludeDisallowedCharacters()
904904
);
905905
}
906906

907+
/**
908+
* @group GH-440
909+
* @dataProvider providerControllerNameDoesNotIncludeDisallowedCharacters
910+
*/
911+
public function testControllerNameDoesNotIncludeDisallowedCharacters($controllerName)
912+
{
913+
$this->request->setControllerName($controllerName)
914+
->setActionName('index');
915+
916+
$this->helper->setActionController(
917+
new Bar_IndexController(
918+
$this->request, $this->response, array()
919+
)
920+
);
921+
922+
$this->assertEquals(
923+
'index/index.phtml', $this->helper->getViewScript()
924+
);
925+
}
926+
927+
/**
928+
* Data provider for testControllerNameDoesNotIncludeDisallowedCharacters
929+
* @group GH-440
930+
* @return array
931+
*/
932+
public function providerControllerNameDoesNotIncludeDisallowedCharacters()
933+
{
934+
return array(
935+
array('!index'),
936+
array('@index'),
937+
array('-index'),
938+
);
939+
}
940+
907941
protected function _normalizePath($path)
908942
{
909943
return str_replace(array('/', '\\'), '/', $path);

0 commit comments

Comments
 (0)