Пример #1
0
 public function testCheckWithDifferentArgSeparator()
 {
     $this->iniSet('arg_separator.output', '&');
     $signer = new UriSigner('foobar');
     $this->assertSame('http://example.com/foo?baz=bay&foo=bar&_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D', $signer->sign('http://example.com/foo?foo=bar&baz=bay'));
     $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay')));
 }
Пример #2
0
 public function testRemovesPathWithControllerNotDefined()
 {
     $signer = new UriSigner('foo');
     $request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1'));
     $listener = new FragmentListener($signer);
     $event = $this->createGetResponseEvent($request);
     $listener->onKernelRequest($event);
     $this->assertFalse($request->query->has('_path'));
 }
 public function testWithSignature()
 {
     $signer = new UriSigner('foo');
     $request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1'));
     $listener = new FragmentListener($signer);
     $event = $this->createGetResponseEvent($request);
     $listener->onKernelRequest($event);
     $this->assertEquals(array('foo' => 'bar', '_controller' => 'foo'), $request->attributes->get('_route_params'));
     $this->assertFalse($request->query->has('_path'));
 }
 public function testCheck()
 {
     $signer = new UriSigner('foobar');
     $this->assertFalse($signer->check('http://example.com/foo?_hash=foo'));
     $this->assertFalse($signer->check('http://example.com/foo?foo=bar&_hash=foo'));
     $this->assertFalse($signer->check('http://example.com/foo?foo=bar&_hash=foo&bar=foo'));
     $this->assertTrue($signer->check($signer->sign('http://example.com/foo')));
     $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar')));
     $this->assertTrue($signer->sign('http://example.com/foo?foo=bar&bar=foo') === $signer->sign('http://example.com/foo?bar=foo&foo=bar'));
 }
Пример #5
0
 public function render($uri, Request $request, array $options = array())
 {
     if ($this->substitute) {
         return $this->defaultStrategy->render($uri, $request, $options);
     }
     if ($this->useHeader && !\strpos($request->headers->get('Surrogate-Capability', ''), 'SSI/1.0')) {
         return $this->defaultStrategy->render($uri, $request, $options);
     }
     if ($uri instanceof ControllerReference) {
         $uri = $this->generateFragmentUri($uri, $request);
     }
     $uri = $this->signer->sign((substr($uri, 0, 1) == "/" ? $request->getSchemeAndHttpHost() : "") . $uri);
     if (!\strncmp($uri, $request->getSchemeAndHttpHost(), \strlen($request->getSchemeAndHttpHost()))) {
         $uri = \substr($uri, \strlen($request->getSchemeAndHttpHost()));
     }
     return new Response(\sprintf('<!--#include virtual="%s" -->', $uri));
 }