Skip to content

Commit

Permalink
Fix EZP-20125: Siteaccess matching error when SA name is in the URL
Browse files Browse the repository at this point in the history
  • Loading branch information
dpobel committed Nov 22, 2012
1 parent 7c75f69 commit bf265d5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
7 changes: 5 additions & 2 deletions eZ/Publish/Core/MVC/Symfony/SiteAccess/Matcher/URIElement.php
Expand Up @@ -104,8 +104,11 @@ public function setRequest( SimplifiedRequest $request )
*/
public function analyseURI( $uri )
{
$uriElements = implode( '/', $this->getURIElements() );
$uri = str_replace( "/$uriElements", '', $uri );
$uriElements = '/' . implode( '/', $this->getURIElements() );
if ( strpos( $uri, $uriElements ) === 0 )
{
sscanf( $uri, "$uriElements%s", $uri );
}
return $uri;
}

Expand Down
Expand Up @@ -117,9 +117,9 @@ public function matchProvider()
* @covers \eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIElement::setRequest
* @covers \eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIElement::getURIElements
*/
public function testAnalyseURI( $uri, $expectedFixedUpURI )
public function testAnalyseURI( $level, $uri, $expectedFixedUpURI )
{
$matcher = new URIElementMatcher( 2 );
$matcher = new URIElementMatcher( $level );
$matcher->setRequest(
new SimplifiedRequest( array( 'pathinfo' => $uri ) )
);
Expand All @@ -132,9 +132,9 @@ public function testAnalyseURI( $uri, $expectedFixedUpURI )
* @dataProvider analyseProvider
* @covers \eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIElement::analyseLink
*/
public function testAnalyseLink( $fullUri, $linkUri )
public function testAnalyseLink( $level, $fullUri, $linkUri )
{
$matcher = new URIElementMatcher( 2 );
$matcher = new URIElementMatcher( $level );
$matcher->setRequest(
new SimplifiedRequest( array( 'pathinfo' => $fullUri ) )
);
Expand All @@ -144,8 +144,13 @@ public function testAnalyseLink( $fullUri, $linkUri )
public function analyseProvider()
{
return array(
array( '/my/siteaccess/foo/bar', '/foo/bar' ),
array( '/vive/le/sucre/en-poudre', '/sucre/en-poudre' )
array( 2, '/my/siteaccess/foo/bar', '/foo/bar' ),
array( 2, '/vive/le/sucre/en-poudre', '/sucre/en-poudre' ),
// Issue https://jira.ez.no/browse/EZP-20125
array( 1, '/fre/content/edit/104/1/fre-FR', '/content/edit/104/1/fre-FR' ),
array( 1, '/fre/utf8-with-accent/é/fre/à/à/fre/é', '/utf8-with-accent/é/fre/à/à/fre/é' ),
array( 2, '/é/fre/utf8-with-accent/é/fre/à/à/fre/é', '/utf8-with-accent/é/fre/à/à/fre/é' ),
array( 2, '/prefix/fre/url/alias/prefix/fre/prefix/fre/url', '/url/alias/prefix/fre/prefix/fre/url' ),
);
}
}

0 comments on commit bf265d5

Please sign in to comment.