summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2011-07-05 11:00:08 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2011-07-05 11:00:08 +0200
commitfffb0ca5c1a284a8d12e72d6d4a83c8a7aba4af5 (patch)
tree7a6a7381cc032ff232d12dbdedbd38cd52250bc5
parentcb2a2651689c5d45fe6e1d6e8d846cfa39e98bc6 (diff)
downloadsymfony-security-fffb0ca5c1a284a8d12e72d6d4a83c8a7aba4af5.zip
symfony-security-fffb0ca5c1a284a8d12e72d6d4a83c8a7aba4af5.tar.gz
symfony-security-fffb0ca5c1a284a8d12e72d6d4a83c8a7aba4af5.tar.bz2
[Security] removed a hack
-rw-r--r--Http/HttpUtils.php23
1 files changed, 14 insertions, 9 deletions
diff --git a/Http/HttpUtils.php b/Http/HttpUtils.php
index 6b674aa..023e45e 100644
--- a/Http/HttpUtils.php
+++ b/Http/HttpUtils.php
@@ -13,7 +13,7 @@ namespace Symfony\Component\Security\Http;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+use Symfony\Component\Routing\RouterInterface;
/**
* Encapsulates the logic needed to create sub-requests, redirect the user, and match URLs.
@@ -22,16 +22,16 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
*/
class HttpUtils
{
- private $urlGenerator;
+ private $router;
/**
* Constructor.
*
- * @param UrlGeneratorInterface $urlGenerator An UrlGeneratorInterface instance
+ * @param RouterInterface $router An RouterInterface instance
*/
- public function __construct(UrlGeneratorInterface $urlGenerator = null)
+ public function __construct(RouterInterface $router = null)
{
- $this->urlGenerator = $urlGenerator;
+ $this->router = $router;
}
/**
@@ -82,7 +82,12 @@ class HttpUtils
public function checkRequestPath(Request $request, $path)
{
if ('/' !== $path[0]) {
- $path = preg_replace('#'.preg_quote($request->getBaseUrl(), '#').'#', '', $this->generateUrl($path));
+ try {
+ $parameters = $this->router->match($request->getPathInfo());
+
+ return $path === $parameters['_route'];
+ } catch (\Exception $e) {
+ }
}
return $path === $request->getPathInfo();
@@ -90,10 +95,10 @@ class HttpUtils
private function generateUrl($route, $absolute = false)
{
- if (null === $this->urlGenerator) {
- throw new \LogicException('You must provide a UrlGeneratorInterface instance to be able to use routes.');
+ if (null === $this->router) {
+ throw new \LogicException('You must provide a RouterInterface instance to be able to use routes.');
}
- return $this->urlGenerator->generate($route, array(), $absolute);
+ return $this->router->generate($route, array(), $absolute);
}
}