8000 Merge branch '2.2' into 2.3 · ftdebugger/symfony@bc256f9 · GitHub
[go: up one dir, main page]

Skip to content

Commit bc256f9

Browse files
committed
Merge branch '2.2' into 2.3
* 2.2: fixed Client when using the terminable event Fix problem with Windows file links (backslash in JavaScript string) [Security] fixed wrong phpdoc [Routing] removed extra argument [HttpFoundation] Header `HTTP_X_FORWARDED_PROTO` can contain various values Some proxies use `ssl` instead of `https`, as well as Lighttpd mod_proxy allows value chaining (`https, http`, where `https` is always first when request is encrypted). Added doc comments Conflicts: src/Symfony/Component/HttpFoundation/Request.php
2 parents a38318b + 66d0b18 commit bc256f9

24 files changed

+117
-20
lines changed

src/Symfony/Bundle/FrameworkBundle/Client.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff lin 1E79 e numberDiff line change
@@ -160,7 +160,7 @@ protected function getScript($request)
160160
$profilerCode = '$kernel->getContainer()->get(\'profiler\')->enable();';
161161
}
162162

163-
return <<<EOF
163+
$code = <<<EOF
164164
<?php
165165
166166
if ('$autoloader') {
@@ -171,7 +171,10 @@ protected function getScript($request)
171171
\$kernel = unserialize('$kernel');
172172
\$kernel->boot();
173173
$profilerCode
174-
echo serialize(\$kernel->handle(unserialize('$request')));
174+
175+
\$request = unserialize('$request');
175176
EOF;
177+
178+
return $code.$this->getHandleScript();
176179
}
177180
}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{% if collector.controller.class is defined %}
66
{% set link = collector.controller.file|file_link(collector.controller.line) %}
77
<span class="sf-toolbar-info-class sf-toolbar-info-with-next-pointer">{{ collector.controller.class|abbr_class }}</span>
8-
<span class="sf-toolbar-info-method" onclick="{% if link %}window.location='{{link}}';window.event.stopPropagation();return false;{% endif %}">
8+
<span class="sf-toolbar-info-method" onclick="{% if link %}window.location='{{link|e('js')}}';window.event.stopPropagation();return false;{% endif %}">
99
{{ collector.controller.method }}
1010
</span>
1111
{% else %}

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ public function getQueryString()
10841084
public function isSecure()
10851085
{
10861086
if (self::$trustedProxies && self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && $proto = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO])) {
1087-
return in_array(strtolower($proto), array('https', 'on', '1'));
1087+
return in_array(strtolower(current(explode(',', $proto))), array('https', 'on', 'ssl', '1'));
10881088
}
10891089

10901090
return 'on' == strtolower($this->server->get('HTTPS')) || 1 == $this->server->get('HTTPS');

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,13 @@ public function testTrustedProxies()
14201420
$this->assertEquals(443, $request->getPort());
14211421
$this->assertTrue($request->isSecure());
14221422

1423+
// check various X_FORWARDED_PROTO header values
1424+
$request->headers->set('X_FORWARDED_PROTO', 'ssl');
1425+
$this->assertTrue($request->isSecure());
1426+
1427+
$request->headers->set('X_FORWARDED_PROTO', 'https, http');
1428+
$this->assertTrue($request->isSecure());
1429+
14231430
// custom header names
14241431
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, 'X_MY_FOR');
14251432
Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, 'X_MY_HOST');

src/Symfony/Component/HttpKernel/Client.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected function getScript($request)
104104
$requirePath = str_replace("'", "\\'", $r->getFileName());
105105
$symfonyPath = str_replace("'", "\\'", realpath(__DIR__.'/../../..'));
106106

107-
return <<<EOF
107+
$code = <<<EOF
108108
<?php
109109
110110
require_once '$requirePath';
@@ -114,7 +114,22 @@ protected function getScript($request)
114114
\$loader->register();
115115
116116
\$kernel = unserialize('$kernel');
117-
echo serialize(\$kernel->handle(unserialize('$request')));
117+
\$request = unserialize('$request');
118+
EOF;
119+
120+
return $code.$this->getHandleScript();
121+
}
122+
123+
protected function getHandleScript()
124+
{
125+
return <<<'EOF'
126+
$response = $kernel->handle($request);
127+
128+
if ($kernel instanceof Symfony\Component\HttpKernel\TerminableInterface) {
129+
$kernel->terminate($request, $response);
130+
}
131+
132+
echo serialize($response);
118133
EOF;
119134
}
120135

src/Symfony/Component/Routing/Router.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function getMatcher()
232232

233233
$class = $this->options['matcher_cache_class'];
234234
$cache = new ConfigCache($this->options['cache_dir'].'/'.$class.'.php', $this->options['debug']);
235-
if (!$cache->isFresh($class)) {
235+
if (!$cache->isFresh()) {
236236
$dumper = new $this->options['matcher_dumper_class']($this->getRouteCollection());
237237

238238
$options = array(
@@ -264,7 +264,7 @@ public function getGenerator()
264264
} else {
265265
$class = $this->options['generator_cache_class'];
266266
$cache = new ConfigCache($this->options['cache_dir'].'/'.$class.'.php', $this->options['debug']);
267-
if (!$cache->isFresh($class)) {
267+
if (!$cache->isFresh()) {
268268
$dumper = new $this->options['generator_dumper_class']($this->getRouteCollection());
269269

270270
$options = array(

src/Symfony/Component/Security/Http/AccessMap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function add(RequestMatcherInterface $requestMatcher, array $roles = arra
3636
$this->map[] = array($requestMatcher, $roles, $channel);
3737
}
3838

39+
/**
40+
* {@inheritDoc}
41+
*/
3942
public function getPatterns(Request $request)
4043
{
4144
foreach ($this->map as $elements) {

src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
6464
{
6565
if ($failureUrl = $request->get($this->options['failure_path_parameter'], null, true)) {
6666
$this->options['failure_path'] = $failureUrl;
67-
}
67+
}
6868

6969
if (null === $this->options['failure_path']) {
7070
$this->options['failure_path'] = $this->options['login_path'];

src/Symfony/Component/Security/Http/Authorization/AccessDeniedHandlerInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Http\Authorization;
1313

1414
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\HttpFoundation\Response;
1516
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
1617
use Symfony\Component\HttpFoundation\Response;
1718

src/Symfony/Component/Security/Http/EntryPoint/BasicAuthenticationEntryPoint.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public function __construct($realmName)
3030
$this->realmName = $realmName;
3131
}
3232

33+
/**
34+
* {@inheritdoc}
35+
*/
3336
public function start(Request $request, AuthenticationException $authException = null)
3437
{
3538
$response = new Response();

src/Symfony/Component/Security/Http/EntryPoint/DigestAuthenticationEntryPoint.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public function __construct($realmName, $key, $nonceValiditySeconds = 300, Logge
3838
$this->logger = $logger;
3939
}
4040

41+
/**
42+
* {@inheritdoc}
43+
*/
4144
public function start(Request $request, AuthenticationException $authException = null)
4245
{
4346
$expiryTime = microtime(true) + $this->nonceValiditySeconds * 1000;
@@ -62,11 +65,17 @@ public function start(Request $request, AuthenticationException $authException =
6265
return $response;
6366
}
6467

68+
/**
69+
* @return string
70+
*/
6571
public function getKey()
6672
{
6773
return $this->key;
6874
}
6975

76+
/**
77+
* @return string
78+
*/
7079
public function getRealmName()
7180
{
7281
return $this->realmName;

src/Symfony/Component/Security/Http/EntryPoint/FormAuthenticationEntryPoint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface
3030
private $httpUtils;
3131

3232
/**
33-
* Constructor
33+
* Constructor.
3434
*
3535
* @param HttpKernelInterface $kernel
3636
* @param HttpUtils $httpUtils An HttpUtils instance

src/Symfony/Component/Security/Http/EntryPoint/RetryAuthenticationEntryPoint.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public function __construct($httpPort = 80, $httpsPort = 443)
3434
$this->httpsPort = $httpsPort;
3535
}
3636

37+
/**
38+
* {@inheritdoc}
39+
*/
3740
public function start(Request $request, AuthenticationException $authException = null)
3841
{
3942
$scheme = $request->isSecure() ? 'http' : 'https';

src/Symfony/Component/Security/Http/Event/InteractiveLoginEvent.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
use Symfony\Component\EventDispatcher\Event;
1616
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1717

18+
/**
19+
* InteractiveLoginEvent
20+
*
21+
* @author Fabien Potencier <fabien@symfony.com>
22+
*/
1823
class InteractiveLoginEvent extends Event
1924
{
2025
private $request;
21-
2226
private $authenticationToken;
2327

2428
/**

src/Symfony/Component/Security/Http/Event/SwitchUserEvent.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
use Symfony\Component\Security\Core\User\UserInterface;
1616
use Symfony\Component\EventDispatcher\Event;
1717

18+
/**
19+
* SwitchUserEvent
20+
*
21+
* @author Fabien Potencier <fabien@symfony.com>
22+
*/
1823
class SwitchUserEvent extends Event
1924
{
2025
private $request;
21-
2226
private $targetUser;
2327

2428
public function __construct(Request $request, UserInterface $targetUser)
@@ -27,11 +31,17 @@ public function __construct(Request $request, UserInterface $targetUser)
2731
$this->targetUser = $targetUser;
2832
}
2933

34+
/**
35+
* @return Request
36+
*/
3037
public function getRequest()
3138
{
3239
return $this->request;
3340
}
3441

42+
/**
43+
* @return UserInterface
44+
*/
3545
public function getTargetUser()
3646
{
3747
return $this->targetUser;

src/Symfony/Component/Security/Http/Firewall.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public function onKernelRequest(GetResponseEvent $event)
7171
}
7272
}
7373

74+
/**
75+
* {@inheritDoc}
76+
*/
7477
public static function getSubscribedEvents()
7578
{
7679
return array(KernelEvents::REQUEST => array('onKernelRequest', 8));

src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ public function onKernelException(GetResponseForExceptionEvent $event)
161161
$event->setResponse($response);
162162
}
163163

164+
/**
165+
* @param Request $request
166+
* @param AuthenticationException $authException
167+
*
168+
* @return Response
169+
* @throws AuthenticationException
170+
*/
164171
private function startAuthentication(Request $request, AuthenticationException $authException)
165172
{
166173
if (null === $this->authenticationEntryPoint) {
@@ -181,6 +188,9 @@ private function startAuthentication(Request $request, AuthenticationException $
181188
return $this->authenticationEntryPoint->start($request, $authException);
182189
}
183190

191+
/**
192+
* @param Request $request
193+
*/
184194
protected function setTargetPath(Request $request)
185195
{
186196
// session isn't required when using http basic authentication mechanism for example

src/Symfony/Component/Security/Http/Firewall/LogoutListener.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class LogoutListener implements ListenerInterface
3737
private $csrfProvider;
3838

3939
/**
40-
* Constructor
40+
* Constructor.
4141
*
4242
* @param SecurityContextInterface $securityContext
4343
* @param HttpUtils $httpUtils An HttpUtilsInterface instance
@@ -77,9 +77,8 @@ public function addHandler(LogoutHandlerInterface $handler)
7777
*
7878
* @param GetResponseEvent $event A GetResponseEvent instance
7979
*
80-
* @throws InvalidCsrfTokenException if the CSRF token is invalid
80+
* @throws LogoutException if the CSRF token is invalid
8181
* @throws \RuntimeException if the LogoutSuccessHandlerInterface instance does not return a response
82-
* @throws LogoutException
8382
*/
8483
public function handle(GetResponseEvent $event)
8584
{

src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class RememberMeListener implements ListenerInterface
3535
private $dispatcher;
3636

3737
/**
38-
* Constructor
38+
* Constructor.
3939
*
4040
* @param SecurityContextInterface $securityContext
4141
* @param RememberMeServicesInterface $rememberMeServices

src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function __construct(SecurityContextInterface $securityContext, Authentic
3636
$this->credentialKey = $credentialKey;
3737
}
3838

39+
/**
40+
* {@inheritdoc}
41+
*/
3942
protected function getPreAuthenticatedData(Request $request)
4043
{
4144
if (!$request->server->has($this->userKey)) {

src/Symfony/Component/Security/Http/FirewallMap.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ class FirewallMap implements FirewallMapInterface
2525
{
2626
private $map = array();
2727

28+
/**
29+
* @param RequestMatcherInterface $requestMatcher
30+
* @param array $listeners
31+
* @param ExceptionListener $exceptionListener
32+
*/
2833
public function add(RequestMatcherInterface $requestMatcher = null, array $listeners = array(), ExceptionListener $exceptionListener = null)
2934
{
3035
$this->map[] = array($requestMatcher, $listeners, $exceptionListener);
3136
}
3237

38+
/**
39+
* {@inheritDoc}
40+
*/
3341
public function getListeners(Request $request)
3442
{
3543
foreach ($this->map as $elements) {

src/Symfony/Component/Security/Http/HttpUtils.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2121
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
2222
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
23-
use Symfony\Component\HttpFoundation\Response;
2423

2524
/**
2625
* Encapsulates the logic needed to create sub-requests, redirect the user, and match URLs.
@@ -37,6 +36,8 @@ class HttpUtils
3736
*
3837
* @param UrlGeneratorInterface $urlGenerator A UrlGeneratorInterface instance
3938
* @param UrlMatcherInterface|RequestMatcherInterface $urlMatcher The Url or Request matcher
39+
*
40+
* @throws \InvalidArgumentException
4041
*/
4142
public function __construct(UrlGeneratorInterface $urlGenerator = null, $urlMatcher = null)
4243
{
@@ -54,7 +55,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator = null, $urlMatc
5455
* @param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo))
5556
* @param integer $status The status code
5657
*
57-
* @return Response A RedirectResponse instance
58+
* @return RedirectResponse A RedirectResponse instance
5859
*/
5960
public function createRedirectResponse(Request $request, $path, $status = 302)
6061
{
@@ -123,9 +124,11 @@ public function checkRequestPath(Request $request, $path)
123124
* Generates a URI, based on the given path or absolute URL.
124125
*
125126
* @param Request $request A Request instance
126-
* @param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo))
127+
* @param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo))
127128
*
128129
* @return string An absolute URL
130+
*
131+
* @throws \LogicException
129132
*/
130133
public function generateUri($request, $path)
131134
{

0 commit comments

Comments
 (0)
0