Merge branch '2.3'
* 2.3: [Locale] fixed build-data exit code in case of an error fixed request format of sub-requests when explicitely set by the developer (closes #8787) Sets _format attribute only if it wasn't set previously by the user. Exclude little words of 'ee' to 'oo' plural transformation fixed the format of the request used to render an exception Fix typo in the check_path validator added a missing use statement (closes #8808) fix for Process:isSuccessful() Include untrusted host in the exception message Conflicts: src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php
This commit is contained in:
commit
167245c9c7
@ -241,6 +241,9 @@ UPGRADE FROM 2.x to 3.0
|
|||||||
* `Symfony\Component\HttpKernel\Exception\FatalErrorException` -> `Symfony\Component\Debug\Exception\FatalErrorException`
|
* `Symfony\Component\HttpKernel\Exception\FatalErrorException` -> `Symfony\Component\Debug\Exception\FatalErrorException`
|
||||||
* `Symfony\Component\HttpKernel\Exception\FlattenException` -> `Symfony\Component\Debug\Exception\FlattenException`
|
* `Symfony\Component\HttpKernel\Exception\FlattenException` -> `Symfony\Component\Debug\Exception\FlattenException`
|
||||||
|
|
||||||
|
* The `Symfony\Component\HttpKernel\EventListener\ExceptionListener` now
|
||||||
|
passes the Request format as the `_format` argument instead of `format`.
|
||||||
|
|
||||||
### Locale
|
### Locale
|
||||||
|
|
||||||
* The Locale component was removed and replaced by the Intl component.
|
* The Locale component was removed and replaced by the Intl component.
|
||||||
|
@ -20,18 +20,27 @@ class FragmentController extends ContainerAware
|
|||||||
{
|
{
|
||||||
$actions = $this->container->get('templating')->get('actions');
|
$actions = $this->container->get('templating')->get('actions');
|
||||||
|
|
||||||
return new Response($actions->render($actions->controller('TestBundle:Fragment:inlined', array(
|
$html1 = $actions->render($actions->controller('TestBundle:Fragment:inlined', array(
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'bar' => new Bar(),
|
'bar' => new Bar(),
|
||||||
'eleven' => 11,
|
'eleven' => 11,
|
||||||
),
|
),
|
||||||
))));
|
)));
|
||||||
|
|
||||||
|
$html2 = $actions->render($actions->controller('TestBundle:Fragment:customformat', array('_format' => 'html')));
|
||||||
|
|
||||||
|
return new Response($html1.'--'.$html2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function inlinedAction($options, $_format)
|
public function inlinedAction($options, $_format)
|
||||||
{
|
{
|
||||||
return new Response($options['bar']->getBar().' '.$_format);
|
return new Response($options['bar']->getBar().' '.$_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function customFormatAction($_format)
|
||||||
|
{
|
||||||
|
return new Response($_format);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Bar
|
class Bar
|
||||||
|
@ -28,7 +28,7 @@ class FragmentTest extends WebTestCase
|
|||||||
|
|
||||||
$client->request('GET', '/fragment_home');
|
$client->request('GET', '/fragment_home');
|
||||||
|
|
||||||
$this->assertEquals('bar txt', $client->getResponse()->getContent());
|
$this->assertEquals('bar txt--html', $client->getResponse()->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfigs()
|
public function getConfigs()
|
||||||
|
@ -287,7 +287,7 @@ class MainConfiguration implements ConfigurationInterface
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false !== strpos('/', $firewall[$k]['check_path']) && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) {
|
if (false !== strpos($firewall[$k]['check_path'], '/') && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) {
|
||||||
throw new \LogicException(sprintf('The check_path "%s" for login method "%s" is not matched by the firewall pattern "%s".', $firewall[$k]['check_path'], $k, $firewall['pattern']));
|
throw new \LogicException(sprintf('The check_path "%s" for login method "%s" is not matched by the firewall pattern "%s".', $firewall[$k]['check_path'], $k, $firewall['pattern']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$container->loadFromExtension('security', array(
|
||||||
|
'providers' => array(
|
||||||
|
'default' => array('id' => 'foo'),
|
||||||
|
),
|
||||||
|
|
||||||
|
'firewalls' => array(
|
||||||
|
'some_firewall' => array(
|
||||||
|
'pattern' => '/secured_area/.*',
|
||||||
|
'form_login' => array(
|
||||||
|
'check_path' => '/some_area/login_check',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
));
|
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<srv:container xmlns="http://symfony.com/schema/dic/security"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||||
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
|
|
||||||
|
<config>
|
||||||
|
<provider name="default" id="foo" />
|
||||||
|
|
||||||
|
<firewall name="some_firewall" pattern="/secured_area/.*">
|
||||||
|
<form-login check-path="/some_area/login_check" />
|
||||||
|
</firewall>
|
||||||
|
</config>
|
||||||
|
|
||||||
|
</srv:container>
|
@ -0,0 +1,9 @@
|
|||||||
|
security:
|
||||||
|
providers:
|
||||||
|
default: { id: foo }
|
||||||
|
|
||||||
|
firewalls:
|
||||||
|
some_firewall:
|
||||||
|
pattern: /secured_area/.*
|
||||||
|
form_login:
|
||||||
|
check_path: /some_area/login_check
|
@ -181,6 +181,15 @@ abstract class SecurityExtensionTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('foo', (string) $container->getAlias('security.acl.provider'));
|
$this->assertEquals('foo', (string) $container->getAlias('security.acl.provider'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||||
|
* @expectedExceptionMessage not matched by the firewall pattern
|
||||||
|
*/
|
||||||
|
public function testInvalidCheckPath()
|
||||||
|
{
|
||||||
|
$container = $this->getContainer('invalid_check_path');
|
||||||
|
}
|
||||||
|
|
||||||
protected function getContainer($file)
|
protected function getContainer($file)
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
@ -39,22 +39,20 @@ class ExceptionController
|
|||||||
* @param Request $request The request
|
* @param Request $request The request
|
||||||
* @param FlattenException $exception A FlattenException instance
|
* @param FlattenException $exception A FlattenException instance
|
||||||
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
|
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
|
||||||
* @param string $format The format to use for rendering (html, xml, ...)
|
* @param string $_format The format to use for rendering (html, xml, ...)
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException When the exception template does not exist
|
* @throws \InvalidArgumentException When the exception template does not exist
|
||||||
*/
|
*/
|
||||||
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
|
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html')
|
||||||
{
|
{
|
||||||
$request->setRequestFormat($format);
|
|
||||||
|
|
||||||
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
|
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
|
||||||
|
|
||||||
$code = $exception->getStatusCode();
|
$code = $exception->getStatusCode();
|
||||||
|
|
||||||
return new Response($this->twig->render(
|
return new Response($this->twig->render(
|
||||||
$this->findTemplate($request, $format, $code, $this->debug),
|
$this->findTemplate($request, $_format, $code, $this->debug),
|
||||||
array(
|
array(
|
||||||
'status_code' => $code,
|
'status_code' => $code,
|
||||||
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
|
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
|
||||||
|
@ -1108,7 +1108,7 @@ class Request
|
|||||||
// as the host can come from the user (HTTP_HOST and depending on the configuration, SERVER_NAME too can come from the user)
|
// as the host can come from the user (HTTP_HOST and depending on the configuration, SERVER_NAME too can come from the user)
|
||||||
// check that it does not contain forbidden characters (see RFC 952 and RFC 2181)
|
// check that it does not contain forbidden characters (see RFC 952 and RFC 2181)
|
||||||
if ($host && !preg_match('/^\[?(?:[a-zA-Z0-9-:\]_]+\.?)+$/', $host)) {
|
if ($host && !preg_match('/^\[?(?:[a-zA-Z0-9-:\]_]+\.?)+$/', $host)) {
|
||||||
throw new \UnexpectedValueException('Invalid Host');
|
throw new \UnexpectedValueException('Invalid Host "'.$host.'"');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count(self::$trustedHostPatterns) > 0) {
|
if (count(self::$trustedHostPatterns) > 0) {
|
||||||
@ -1126,7 +1126,7 @@ class Request
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \UnexpectedValueException('Untrusted Host');
|
throw new \UnexpectedValueException('Untrusted Host "'.$host.'"');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $host;
|
return $host;
|
||||||
|
@ -1536,7 +1536,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
$request->getHost();
|
$request->getHost();
|
||||||
$this->fail('Request::getHost() should throw an exception when host is not trusted.');
|
$this->fail('Request::getHost() should throw an exception when host is not trusted.');
|
||||||
} catch (\UnexpectedValueException $e) {
|
} catch (\UnexpectedValueException $e) {
|
||||||
$this->assertEquals('Untrusted Host', $e->getMessage());
|
$this->assertEquals('Untrusted Host "evil.com"', $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// trusted hosts
|
// trusted hosts
|
||||||
|
@ -114,6 +114,10 @@ class ExceptionListener implements EventSubscriberInterface
|
|||||||
'_controller' => $this->controller,
|
'_controller' => $this->controller,
|
||||||
'exception' => FlattenException::create($exception),
|
'exception' => FlattenException::create($exception),
|
||||||
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
|
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
|
||||||
|
'_format' => $request->getRequestFormat(),
|
||||||
|
// keep for BC -- as $format can be an argument of the controller callable
|
||||||
|
// see src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php
|
||||||
|
// @deprecated in 2.4, to be removed in 3.0
|
||||||
'format' => $request->getRequestFormat(),
|
'format' => $request->getRequestFormat(),
|
||||||
);
|
);
|
||||||
$request = $request->duplicate(null, null, $attributes);
|
$request = $request->duplicate(null, null, $attributes);
|
||||||
|
@ -60,7 +60,14 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer
|
|||||||
// below instead)
|
// below instead)
|
||||||
$attributes = $reference->attributes;
|
$attributes = $reference->attributes;
|
||||||
$reference->attributes = array();
|
$reference->attributes = array();
|
||||||
|
|
||||||
|
// The request format might have been overriden by the user
|
||||||
|
if (isset($attributes['_format'])) {
|
||||||
|
$reference->attributes['_format'] = $attributes['_format'];
|
||||||
|
}
|
||||||
|
|
||||||
$uri = $this->generateFragmentUri($uri, $request, false);
|
$uri = $this->generateFragmentUri($uri, $request, false);
|
||||||
|
|
||||||
$reference->attributes = array_merge($attributes, $reference->attributes);
|
$reference->attributes = array_merge($attributes, $reference->attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ class Process
|
|||||||
*/
|
*/
|
||||||
public function isSuccessful()
|
public function isSuccessful()
|
||||||
{
|
{
|
||||||
return 0 == $this->getExitCode();
|
return 0 === $this->getExitCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -307,6 +307,18 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($process->isSuccessful());
|
$this->assertTrue($process->isSuccessful());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIsSuccessfulOnlyAfterTerminated()
|
||||||
|
{
|
||||||
|
$process = $this->getProcess('sleep 1');
|
||||||
|
$process->start();
|
||||||
|
while ($process->isRunning()) {
|
||||||
|
$this->assertFalse($process->isSuccessful());
|
||||||
|
usleep(300000);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertTrue($process->isSuccessful());
|
||||||
|
}
|
||||||
|
|
||||||
public function testIsNotSuccessful()
|
public function testIsNotSuccessful()
|
||||||
{
|
{
|
||||||
$process = $this->getProcess('php -r "sleep(4);"');
|
$process = $this->getProcess('php -r "sleep(4);"');
|
||||||
|
@ -128,6 +128,14 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
parent::testIsSuccessful();
|
parent::testIsSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
*/
|
||||||
|
public function testIsSuccessfulOnlyAfterTerminated()
|
||||||
|
{
|
||||||
|
parent::testIsSuccessfulOnlyAfterTerminated();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
|
@ -188,7 +188,7 @@ class StringUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert teeth to tooth, feet to foot
|
// Convert teeth to tooth, feet to foot
|
||||||
if (false !== ($pos = strpos($plural, 'ee'))) {
|
if (false !== ($pos = strpos($plural, 'ee')) && strlen($plural) > 3) {
|
||||||
return substr_replace($plural, 'oo', $pos, 2);
|
return substr_replace($plural, 'oo', $pos, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerI
|
|||||||
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
|
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
|
||||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||||
use Symfony\Component\Security\Core\Exception\SessionUnavailableException;
|
use Symfony\Component\Security\Core\Exception\SessionUnavailableException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
Reference in New Issue
Block a user