Merge branch '2.7' into 2.8

* 2.7:
  [Security] Fix wrong term in UserProviderInterface
  [HttpFoundation] Set meta refresh time to 0 in RedirectResponse content
  [Security] validate empty passwords again
  [DI] Remove irrelevant comment from container
  [TwigBridge] cleaner implementation of the TwigRenderer
This commit is contained in:
Fabien Potencier 2017-07-17 16:02:19 +02:00
commit f49cc11021
7 changed files with 40 additions and 22 deletions

View File

@ -19,16 +19,19 @@ use Twig\Environment;
*/
class TwigRenderer extends FormRenderer implements TwigRendererInterface
{
/**
* @var TwigRendererEngineInterface
*/
private $engine;
public function __construct(TwigRendererEngineInterface $engine, $csrfTokenManager = null)
{
parent::__construct($engine, $csrfTokenManager);
}
$this->engine = $engine;
/**
* Returns the engine used by this renderer.
*
* @return TwigRendererEngineInterface The renderer engine
*/
public function getEngine()
{
return parent::getEngine();
}
/**
@ -36,6 +39,6 @@ class TwigRenderer extends FormRenderer implements TwigRendererInterface
*/
public function setEnvironment(Environment $environment)
{
$this->engine->setEnvironment($environment);
$this->getEngine()->setEnvironment($environment);
}
}

View File

@ -30,16 +30,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
*
* Parameter and service keys are case insensitive.
*
* A service id can contain lowercased letters, digits, underscores, and dots.
* Underscores are used to separate words, and dots to group services
* under namespaces:
*
* <ul>
* <li>request</li>
* <li>mysql_session_storage</li>
* <li>symfony.mysql_session_storage</li>
* </ul>
*
* A service can also be defined by creating a method named
* getXXXService(), where XXX is the camelized version of the id:
*

View File

@ -134,8 +134,8 @@ class ContainerTest extends TestCase
public function testSet()
{
$sc = new Container();
$sc->set('foo', $foo = new \stdClass());
$this->assertSame($foo, $sc->get('foo'), '->set() sets a service');
$sc->set('._. \\o/', $foo = new \stdClass());
$this->assertSame($foo, $sc->get('._. \\o/'), '->set() sets a service');
}
public function testSetWithNullResetTheService()

View File

@ -83,7 +83,7 @@ class RedirectResponse extends Response
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="1;url=%1$s" />
<meta http-equiv="refresh" content="0;url=%1$s" />
<title>Redirecting to %1$s</title>
</head>

View File

@ -90,6 +90,29 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
->assertRaised();
}
/**
* @dataProvider emptyPasswordData
*/
public function testEmptyPasswordsAreNotValid($password)
{
$constraint = new UserPassword(array(
'message' => 'myMessage',
));
$this->validator->validate($password, $constraint);
$this->buildViolation('myMessage')
->assertRaised();
}
public function emptyPasswordData()
{
return array(
array(null),
array(''),
);
}
/**
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
*/

View File

@ -48,7 +48,7 @@ interface UserProviderInterface
public function loadUserByUsername($username);
/**
* Refreshes the user for the account interface.
* Refreshes the user.
*
* It is up to the implementation to decide if the user data should be
* totally reloaded (e.g. from the database), or if the UserInterface
@ -59,7 +59,7 @@ interface UserProviderInterface
*
* @return UserInterface
*
* @throws UnsupportedUserException if the account is not supported
* @throws UnsupportedUserException if the user is not supported
*/
public function refreshUser(UserInterface $user);

View File

@ -40,6 +40,8 @@ class UserPasswordValidator extends ConstraintValidator
}
if (null === $password || '' === $password) {
$this->context->addViolation($constraint->message);
return;
}