Issues

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

Issue Type: Bug Created: 2011-06-20T14:04:06.000+0000 Last Updated: 2011-06-20T14:04:06.000+0000 Status: Open Fix version(s): Reporter: Pablo Grass (grass) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Controller_Router

Related issues: Attachments:

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

<pre class="literal"> 
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('<a href="http://host/foo_a/go">http://host/foo_a/go</a>');
        $matchedRoute = $router->route($request);

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

        $request = new Zend_Controller_Request_Http('<a href="http://host/foo_lorem+ipsum/go">http://host/foo_lorem+ipsum/go</a>');
        $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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts