8000 Merge branch '4.2' · symfony/symfony@98929dc · GitHub
[go: up one dir, main page]

Skip to content

Commit 98929dc

Browse files
Merge branch '4.2'
* 4.2: [HttpFoundation] fix tests [Routing] fix trailing slash matching with empty-matching trailing vars [Routing] fix matching trailing vars with defaults [Validator] fix LegacyTranslatorProxy call method with Translator component only bumped Symfony version to 4.2.8 updated VERSION for 4.2.7 updated CHANGELOG for 4.2.7 bumped Symfony version to 3.4.27 updated VERSION for 3.4.26 updated CHANGELOG for 3.4.26
2 parents 823d375 + bff2db7 commit 98929dc

File tree

10 files changed

+84
-11
lines changed

10 files changed

+84
-11
lines changed

CHANGELOG-4.2.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ in 4.2 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.2.0...v4.2.1
99

10+
* 4.2.7 (2019-04-17)
11+
12+
* bug #31107 [Routing] fix trailing slash redirection with non-greedy trailing vars (nicolas-grekas)
13+
* bug #31108 [FrameworkBundle] decorate the ValidatorBuilder's translator with LegacyTranslatorProxy (nicolas-grekas)
14+
* bug #31121 [HttpKernel] Fix get session when the request stack is empty (yceruto)
15+
* bug #31084 [HttpFoundation] Make MimeTypeExtensionGuesser case insensitive (vermeirentony)
16+
* bug #31142 Revert "bug #30423 [Security] Rework firewall's access denied rule (dimabory)" (chalasr)
17+
* security #cve-2019-10910 [DI] Check service IDs are valid (nicolas-grekas)
18+
* security #cve-2019-10909 [FrameworkBundle][Form] Fix XSS issues in the form theme of the PHP templating engine (stof)
19+
* security #cve-2019-10912 [Cache][PHPUnit Bridge] Prevent destructors with side-effects from being unserialized (nicolas-grekas)
20+
* security #cve-2019-10911 [Security] Add a separator in the remember me cookie hash (pborreli)
21+
* security #cve-2019-10913 [HttpFoundation] reject invalid method override (nicolas-grekas)
22+
1023
* 4.2.6 (2019-04-16)
1124

1225
* bug #31088 [DI] fix removing non-shared definition while inlining them (nicolas-grekas)

phpunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
22
<?php
33

4-
// Cache-Id: https://github.com/symfony/symfony/commit/aad0c58
4+
// Cache-Id: https://github.com/symfony/phpunit-bridge/commit/32c5fa570117630dad45c21528b93d26bad02bc1
55

66
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
77
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
use Symfony\Component\Stopwatch\Stopwatch;
108108
use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand;
109109
use Symfony\Component\Translation\Translator;
110+
use Symfony\Component\Translation\TranslatorInterface;
110111
use Symfony\Component\Validator\ConstraintValidatorInterface;
111112
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
112113
use Symfony\Component\Validator\ObjectInitializerInterface;
@@ -1209,7 +1210,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
12091210

12101211
$validatorBuilder = $container->getDefinition('validator.builder');
12111212

1212-
if (class_exists(LegacyTranslatorProxy::class)) {
1213+
if (interface_exists(TranslatorInterface::class) && class_exists(LegacyTranslatorProxy::class)) {
12131214
$calls = $validatorBuilder->getMethodCalls();
12141215
$calls[1] = ['setTranslator', [new Definition(LegacyTranslatorProxy::class, [new Reference('translator')])]];
12151216
$validatorBuilder->setMethodCalls($calls);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
5454
use Symfony\Component\Serializer\Serializer;
5555
use Symfony\Component\Translation\DependencyInjection\TranslatorPass;
56+
use Symfony\Component\Translation\TranslatorInterface;
5657
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
5758
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
5859
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
@@ -883,7 +884,7 @@ public function testValidation()
883884
$this->assertSame('setConstraintValidatorFactory', $calls[0][0]);
884885
$this->assertEquals([new Reference('validator.validator_factory')], $calls[0][1]);
885886
$this->assertSame('setTranslator', $calls[1][0]);
886-
if (class_exists(LegacyTranslatorProxy::class)) {
887+
if (interface_exists(TranslatorInterface::class) && class_exists(LegacyTranslatorProxy::class)) {
887888
$this->assertEquals([new Definition(LegacyTranslatorProxy::class, [new Reference('translator')])], $calls[1][1]);
888889
} else {
889890
$this->assertEquals([new Reference('translator')], $calls[1][1]);

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,14 +1004,15 @@ public function ianaCodesReasonPhrasesProvider()
10041004

10051005
$ianaHttpStatusCodes = new \DOMDocument();
10061006

1007-
libxml_set_streams_context(stream_context_create([
1007+
$context = stream_context_create([
10081008
'http' => [
10091009
'method' => 'GET',
10101010
'timeout' => 30,
1011+
'user_agent' => __METHOD__,
10111012
],
1012-
]));
1013+
]);
10131014

1014-
$ianaHttpStatusCodes->load('https://www.iana.org/assignments/http-status-codes/http-status-codes.xml');
1015+
$ianaHttpStatusCodes->loadXML(file_get_contents('https://www.iana.org/assignments/http-status-codes/http-status-codes.xml', false, $context));
10151016
if (!$ianaHttpStatusCodes->relaxNGValidate(__DIR__.'/schema/http-status-codes.rng')) {
10161017
self::fail('Invalid IANA\'s HTTP status code list.');
10171018
}

src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private function doMatch(string $pathinfo, array &$allow = [], array &$allowSche
137137

138138
$hasTrailingVar = $trimmedPathinfo !== $pathinfo && $hasTrailingVar;
139139

140-
if ($hasTrailingVar && ($hasTrailingSlash || '/' !== substr($matches[\count($vars)], -1)) && preg_match($regex, $this->matchHost ? $host.'.'.$trimmedPathinfo : $trimmedPathinfo, $n) && $m === (int) $n['MARK']) {
140+
if ($hasTrailingVar && ($hasTrailingSlash || (null === $n = $matches[\count($vars)] ?? null) || '/' !== ($n[-1] ?? '/')) && preg_match($regex, $this->matchHost ? $host.'.'.$trimmedPathinfo : $trimmedPathinfo, $n) && $m === (int) $n['MARK']) {
141141
if ($hasTrailingSlash) {
142142
$matches = $n;
143143
} else {

src/Symfony/Component/Routing/Matcher/UrlMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
158158

159159
$hasTrailingVar = $trimmedPathinfo !== $pathinfo && preg_match('#\{\w+\}/?$#', $route->getPath());
160160

161-
if ($hasTrailingVar && ($hasTrailingSlash || '/' !== substr($matches[(\count($matches) - 1) >> 1], -1)) && preg_match($regex, $trimmedPathinfo, $m)) {
161+
if ($hasTrailingVar && ($hasTrailingSlash || (null === $m = $matches[\count($compiledRoute->getPathVariables())] ?? null) || '/' !== ($m[-1] ?? '/')) && preg_match($regex, $trimmedPathinfo, $m)) {
162162
if ($hasTrailingSlash) {
163163
$matches = $m;
164164
} else {

src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,17 @@ public function testNonGreedyTrailingRequirement()
198198
$this->assertEquals(['_route' => 'a', 'a' => '123'], $matcher->match('/123/'));
199199
}
200200

201+
public function testTrailingRequirementWithDefault_A()
202+
{
203+
$coll = new RouteCollection();
204+
$coll->add('a', new Route('/fr-fr/{a}', ['a' => 'aaa'], ['a' => '.+']));
205+
206+
$matcher = $this->getUrlMatcher($coll);
207+
$matcher->expects($this->once())->method('redirect')->with('/fr-fr')->willReturn([]);
208+
209+
$this->assertEquals(['_route' => 'a', 'a' => 'aaa'], $matcher->match('/fr-fr/'));
210+
}
211+
201212
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)
202213
{
203214
return $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', [$routes, $context ?: new RequestContext()]);

src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,41 @@ public function testGreedyTrailingRequirement()
777777
$this->assertEquals(['_route' => 'a', 'a' => 'foo/'], $matcher->match('/foo/'));
778778
}
779779

780+
public function testTrailingRequirementWithDefault()
781+
{
782+
$coll = new RouteCollection();
783+
$coll->add('a', new Route('/fr-fr/{a}', ['a' => 'aaa'], ['a' => '.+']));
784+
$coll->add('b', new Route('/en-en/{b}', ['b' => 'bbb'], ['b' => '.*']));
785+
786+
$matcher = $this->getUrlMatcher($coll);
787+
788+
$this->assertEquals(['_route' => 'a', 'a' => 'aaa'], $matcher->match('/fr-fr'));
789+
$this->assertEquals(['_route' => 'a', 'a' => 'AAA'], $matcher->match('/fr-fr/AAA'));
790+
$this->assertEquals(['_route' => 'b', 'b' => 'bbb'], $matcher->match('/en-en'));
791+
$this->assertEquals(['_route' => 'b', 'b' => 'BBB'], $matcher->match('/en-en/BBB'));
792+
}
793+
794+
public function testTrailingRequirementWithDefault_A()
795+
{
796+
$coll = new RouteCollection();
797+
$coll->add('a', new Route('/fr-fr/{a}', ['a' => 'aaa'], ['a' => '.+']));
798+
799+
$matcher = $this->getUrlMatcher($coll);
800+
801+
$this->expectException(ResourceNotFoundException::class);
802+
$matcher->match('/fr-fr/');
803+
}
804+
805+
public function testTrailingRequirementWithDefault_B()
806+
{
807+
$coll = new RouteCollection();
808+
$coll->add('b', new Route('/en-en/{b}', ['b' => 'bbb'], ['b' => '.*']));
809+
810+
$matcher = $this->getUrlMatcher($coll);
811+
812+
$this->assertEquals(['_route' => 'b', 'b' => ''], $matcher->match('/en-en/'));
813+
}
814+
780815
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)
781816
{
782817
return new UrlMatcher($routes, $context ?: new RequestContext());

src/Symfony/Component/Validator/Util/LegacyTranslatorProxy.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,26 @@ class LegacyTranslatorProxy implements LegacyTranslatorInterface, TranslatorInte
2222
{
2323
private $translator;
2424

25-
public function __construct(TranslatorInterface $translator)
25+
/**
26+
* @param LegacyTranslatorInterface|TranslatorInterface $translator
27+
*/
28+
public function __construct($translator)
2629
{
27-
if (!$translator instanceof LocaleAwareInterface) {
30+
if ($translator instanceof LegacyTranslatorInterface) {
31+
// no-op
32+
} elseif (!$translator instanceof TranslatorInterface) {
33+
throw new \InvalidArgumentException(sprintf('The translator passed to "%s()" must implement "%s" or "%s".', __METHOD__, TranslatorInterface::class, LegacyTranslatorInterface::class));
34+
} elseif (!$translator instanceof LocaleAwareInterface) {
2835
throw new \InvalidArgumentException(sprintf('The translator passed to "%s()" must implement "%s".', __METHOD__, LocaleAwareInterface::class));
2936
}
37+
3038
$this->translator = $translator;
3139
}
3240

33-
public function getTranslator(): TranslatorInterface
41+
/**
42+
* @return LegacyTranslatorInterface|TranslatorInterface
43+
*/
44+
public function getTranslator()
3445
{
3546
return $this->translator;
3647
}

0 commit comments

Comments
 (0)
0