Skip to content

Commit 8dd31df

Browse files
committed
Merge pull request #260 from symfony-cmf/handle_colon_in_url
do not allow colon inside a PHPCR route uri
2 parents b5d0574 + 06749d9 commit 8dd31df

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Changelog
22
=========
33

4+
* **2014-08-07**: PHPCR RouteProvider no longer allows colons in the URI as they are
5+
interpreted as namespaces, leading to errors.
46
* **2014-06-06**: Updated to PSR-4 autoloading
57

68
1.2.0

Doctrine/Phpcr/RouteProvider.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ public function __construct(
5959
$this->logger = $logger;
6060
}
6161

62+
/**
63+
* @param Request $request
64+
*
65+
* @return array a list of PHPCR-ODM ids
66+
*/
67+
public function getCandidates(Request $request)
68+
{
69+
if (false !== strpos($request->getPathInfo(), ':')) {
70+
return array();
71+
}
72+
73+
return $this->candidatesStrategy->getCandidates($request);
74+
}
75+
6276
/**
6377
* {@inheritDoc}
6478
*
@@ -69,7 +83,7 @@ public function __construct(
6983
*/
7084
public function getRouteCollectionForRequest(Request $request)
7185
{
72-
$candidates = $this->candidatesStrategy->getCandidates($request);
86+
$candidates = $this->getCandidates($request);
7387

7488
$collection = new RouteCollection();
7589

Tests/Functional/Doctrine/Phpcr/RouteProviderTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,26 @@ public function testGetRouteCollectionForRequestFormat()
101101
/**
102102
* The root route will always be found.
103103
*/
104-
public function testGetRouteCollectionForRequestNophpcrUrl()
104+
public function testGetRouteCollectionForRequestNonPhpcrUrl()
105105
{
106-
$collection = $this->repository->getRouteCollectionForRequest(Request::create(':///'));
106+
$collection = $this->repository->getRouteCollectionForRequest(Request::create('http:///'));
107107
$this->assertInstanceOf('Symfony\Component\Routing\RouteCollection', $collection);
108108
$this->assertCount(1, $collection);
109109
$routes = $collection->all();
110110
list ($key, $route) = each($routes);
111111
$this->assertEquals(self::ROUTE_ROOT, $key);
112112
}
113113

114+
/**
115+
* The root route will always be found.
116+
*/
117+
public function testGetRouteCollectionForRequestColonInUrl()
118+
{
119+
$collection = $this->repository->getRouteCollectionForRequest(Request::create('http://foo.com/jcr:content'));
120+
$this->assertInstanceOf('Symfony\Component\Routing\RouteCollection', $collection);
121+
$this->assertCount(0, $collection);
122+
}
123+
114124
public function testGetRoutesByNames()
115125
{
116126
$this->buildRoutes();

0 commit comments

Comments
 (0)