Issues

ZF-11496: Regex routes in chains fail to urldecode parameters

Description

When using a Regex Route as part of a Chain (the Regex Route becomes a partial), the parameters belonging to the Regex Route do not get urldecoded.

The following test case does pass in 1.11.5 and before. Since 1.11.6., the third assertion fails

 
class ZendTest extends PHPUnit_Framework_TestCase {

    public function testRegexInChainUrlDecode() {
        $router = new Zend_Controller_Router_Rewrite();
        $foo = new Zend_Controller_Router_Route_Regex(
            'foo_([^/]+)',
            array(),
            array('first' => 1),
            'foo_%s'
        );
        $foo->isAbstract(true);
        $router->addRoute('foo', $foo);
        $bar = new Zend_Controller_Router_Route(':action/');
        $bar->isAbstract(true);
        $router->addRoute('bar', $bar);
        $chain = new Zend_Controller_Router_Route_Chain();
        $chain->chain($foo);
        $chain->chain($bar);
        $router->addRoute('chain', $chain);

        $this->assertEquals(
            '/foo_a/go',
            $router->assemble(array('first' => 'a', 'action' => 'go'), 'chain', true),
            'assembling with all parameters given'
        );

        $request = new Zend_Controller_Request_Http('http://host/foo_a/go');
        $matchedRoute = $router->route($request);

        $this->assertEquals(
            array('first' => 'a', 'action' => 'go'),
            $matchedRoute->getParams(),
            'matching simple url'
        );

        $request = new Zend_Controller_Request_Http('http://host/foo_lorem+ipsum/go');
        $matchedRoute = $router->route($request);

        $this->assertEquals(
            array('first' => 'lorem ipsum', 'action' => 'go'),
            $matchedRoute->getParams(),  // sadly gives us "lorem+ipsum"
            'matching url with url-encoded "first" parmeter'
        );
    }
}

Comments

No comments to display