8000 Merge branch '2.5' into 2.6 · guilhermeblanco/symfony@2f6d5e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f6d5e4

Browse files
committed
Merge branch '2.5' into 2.6
* 2.5: fixxed order of usage [2.7] [Form] Replaced calls to array_search() by in_array() where is no need to get the index [Process] Make test AbstractProcessTest::testStartAfterATimeout useful again [Validator] Remove unnecessary include in tests [HttpFoundation] minor: clarify Request::getUrlencodedPrefix() regex fixed typo [Validator] fix DOS-style line endings bumped Symfony version to 2.5.11 updated VERSION for 2.5.10 updated CHANGELOG for 2.5.10 [Validator] Add a Russian translation for invalid charset message [2.3] [Validator] spanish translation for invalid charset message [Routing] make host matching case-insensitive according to RFC 3986 Conflicts: src/Symfony/Component/Console/Application.php src/Symfony/Component/Console/Tests/Fixtures/application_1.txt src/Symfony/Component/Console/Tests/Fixtures/application_2.txt src/Symfony/Component/Console/Tests/Fixtures/application_astext1.txt src/Symfony/Component/Console/Tests/Fixtures/application_astext2.txt src/Symfony/Component/Console/Tests/Fixtures/application_gethelp.txt src/Symfony/Component/Console/Tests/Fixtures/application_run1.txt src/Symfony/Component/HttpKernel/Kernel.php src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf src/Symfony/Component/Validator/Resources/translations/validators.es.xlf src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf
2 parents 82c4eda + f7a1adb commit 2f6d5e4

File tree

26 files changed

+401
-338
lines changed

26 files changed

+401
-338
lines changed

CHANGELOG-2.5.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,35 @@ in 2.5 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/v2.5.0...v2.5.1
99

10+
* 2.5.10 (2015-02-02)
11+
12+
* bug #13528 [Validator] reject ill-formed strings (nicolas-grekas)
13+
* bug #13525 [Validator] UniqueEntityValidator - invalidValue fixed. (Dawid Sajdak)
14+
* bug #13549 [EventDispatcher] Wrong EventDispatcher instance injected in listeners (dosten)
15+
* bug #13527 [Validator] drop grapheme_strlen in LengthValidator (nicolas-grekas)
16+
* bug #13376 [FrameworkBundle][config] allow multiple fallback locales. (aitboudad)
17+
* bug #12972 Make the container considered non-fresh if the environment parameters are changed (thewilkybarkid)
18+
* bug #13309 [Console] fixed 10531 (nacmartin)
19+
* bug #13352 [Yaml] fixed parse shortcut Key after unindented collection. (aitboudad)
20+
* bug #13343 [FrameworkBundle] FormDataCollector should be loaded only if form config is enabled (hason)
21+
* bug #13039 [HttpFoundation] [Request] fix baseUrl parsing to fix wrong path_info (rk3rn3r)
22+
* bug #13250 [Twig][Bridge][TranslationDefaultDomain] add support of named arguments. (aitboudad)
23+
* bug #13332 [Console] ArgvInput and empty tokens (Taluu)
24+
* bug #13293 [EventDispatcher] Add missing checks to RegisterListenersPass (znerol)
25+
* bug #13262 [Yaml] Improve YAML boolean escaping (petert82, larowlan)
26+
* bug #13420 [Debug] fix loading order for legacy classes (nicolas-grekas)
27+
* bug #13421 [FrameworkBundle] fix routing descriptor for options (Tobion)
28+
* bug #13405 [TwigBridge] exit when Twig environment is not set in the LintCommand (xabbuh)
29+
* bug #13371 fix missing comma in YamlDumper (garak)
30+
* bug #13365 [HttpFoundation] Make use of isEmpty() method (xelaris)
31+
* bug #13355 [Console] Helper\Table->addRow optimization (boekkooi)
32+
* bug #13347 [Console] Helper\TableHelper->addRow optimization (boekkooi)
33+
* bug #13346 [PropertyAccessor] Allow null value for a array (2.3) (boekkooi)
34+
* bug #13170 [Form] Set a child type to text if added to the form without a type. (jakzal)
35+
* bug #13334 [Yaml] Fixed #10597: Improved Yaml directive parsing (VictoriaQ)
36+
* bug #13316 [Form] fixed the CSRF extension to allow using only the new interfaces (fabpot)
37+
* bug #13305 [FrameworkBundle] fixed missing information in some descriptors (fabpot)
38+
1039
* 2.5.9 (2015-01-07)
1140

1241
* bug #13286 [Security] Don't destroy the session on buggy php releases. (derrabus)

src/Symfony/Bridge/Twig/Extension/FormExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function humanize($text)
144144
public function isSelectedChoice(ChoiceView $choice, $selectedValue)
145145
{
146146
if (is_array($selectedValue)) {
147-
return false !== array_search($choice->value, $selectedValue, true);
147+
return in_array($choice->value, $selectedValue, true);
148148
}
149149

150150
return $choice->value === $selectedValue;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public function testTranslator()
261261
$this->assertEquals(array('fr'), $calls[0][1][0]);
262262
}
263263

264-
public function testTranslatorMultipleFullback()
264+
public function testTranslatorMultipleFallbacks()
265265
{
266266
$container = $this->createContainerFromFile('translator_fallbacks');
267267

src/Symfony/Component/Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ protected function describeApplication(Application $application, array $options
164164
}
165165

166166
$this->writeText("<comment>Usage:</comment>\n", $options);
167-
$this->writeText(" [options] command [arguments]\n\n", $options);
167+
$this->writeText(" command [options] [arguments]\n\n", $options);
168168
$this->writeText('<comment>Options:</comment>', $options);
169169

170170
$inputOptions = $application->getDefinition()->getOptions();

src/Symfony/Component/Console/Tests/Fixtures/application_1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<info>Console Tool</info>
22

33
<comment>Usage:</comment>
4-
[options] command [arguments]
4+
command [options] [arguments]
55

66
<comment>Options:</comment>
77
<info>--help</info> (-h) Display this help message

src/Symfony/Component/Console/Tests/Fixtures/application_2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<info>My Symfony application</info> version <comment>v1.0</comment>
22

33
<comment>Usage:</comment>
4-
[options] command [arguments]
4+
command [options] [arguments]
55

66
<comment>Options:</comment>
77
<info>--help</info> (-h) Display this help message

src/Symfony/Component/Console/Tests/Fixtures/application_astext1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<info>Console Tool</info>
22

33
<comment>Usage:</comment>
4-
[options] command [arguments]
4+
command [options] [arguments]
55

66
<comment>Options:</comment>
77
<info>--help</info> (-h) Display this help message

src/Symfony/Component/Console/Tests/Fixtures/application_astext2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<info>Console Tool</info>
22

33
<comment>Usage:</comment>
4-
[options] command [arguments]
4+
command [options] [arguments]
55

66
<comment>Options:</comment>
77
<info>--help</info> (-h) Display this help message

src/Symfony/Component/Console/Tests/Fixtures/application_run1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Console Tool
22

33
Usage:
4-
[options] command [arguments]
4+
command [options] [arguments]
55

66
Options:
77
--help (-h) Display this help message

src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ protected function addChoice(array &$bucketForPreferred, array &$bucketForRemain
385385
*/
386386
protected function isPreferred($choice, array $preferredChoices)
387387
{
388-
return false !== array_search($choice, $preferredChoices, true);
388+
return in_array($choice, $preferredChoices, true);
389389
}
390390

391391
/**

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
110110
// avoid making the type check inside the closure.
111111
if ($options['multiple']) {
112112
$view->vars['is_selected'] = function ($choice, array $values) {
113-
return false !== array_search($choice, $values, true);
113+
return in_array($choice, $values, true);
114114
};
115115
} else {
116116
$view->vars['is_selected'] = function ($choice, $value) {
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
<?xml version="1.0"?>
2-
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3-
<file source-language="en" datatype="plaintext" original="file.ext">
4-
<body>
5-
<trans-unit id="28">
6-
<source>This form should not contain extra fields.</source>
7-
<target>Тази форма не трябва да съдържа допълнителни полета.</target>
8-
</trans-unit>
9-
<trans-unit id="29">
10-
<source>The uploaded file was too large. Please try to upload a smaller file.</source>
11-
<target>Каченият файл е твърде голям. Моля, опитайте да качите по-малък файл.</target>
12-
</trans-unit>
13-
<trans-unit id="30">
14-
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
15-
<target>Невалиден CSRF токен. Моля, опитайте да изпратите формата отново.</target>
16-
</trans-unit>
17-
</body>
18-
</file>
19-
</xliff>
1+
<?xml version="1.0"?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="file.ext">
4+
<body>
5+
<trans-unit id="28">
6+
<source>This form should not contain extra fields.</source>
7+
<target>Тази форма не трябва да съдържа допълнителни полета.</target>
8+
</trans-unit>
9+
<trans-unit id="29">
10+
<source>The uploaded file was too large. Please try to upload a smaller file.</source>
11+
<target>Каченият файл е твърде голям. Моля, опитайте да качите по-малък файл.</target>
12+
</trans-unit>
13+
<trans-unit id="30">
14+
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
15+
<target>Невалиден CSRF токен. Моля, опитайте да изпратите формата отново.</target>
16+
</trans-unit>
17+
</body>
18+
</file>
19+
</xliff>

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ private function getUrlencodedPrefix($string, $prefix)
18961896

18971897
$len = strlen($prefix);
18981898

1899-
if (preg_match("#^(%[[:xdigit:]]{2}|.){{$len}}#", $string, $match)) {
1899+
if (preg_match(sprintf('#^(%%[[:xdigit:]]{2}|.){%d}#', $len), $string, $match)) {
19001900
return $match[0];
19011901
}
19021902

src/Symfony/Component/Process/Tests/AbstractProcessTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,13 +841,13 @@ public function testIdleTimeoutNotExceededWhenOutputIsSent()
841841

842842
public function testStartAfterATimeout()
843843
{
844-
$process = $this->getProcess('php -r "$n = 1000; while ($n--) {echo \'\'; usleep(1000); }"');
844+
$process = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 1000; while ($n--) {echo \'\'; usleep(1000); }')));
845845
$process->setTimeout(0.1);
846846

847847
try {
848848
$process->run();
849-
$this->fail('An exception should have been raised.');
850-
} catch (\Exception $e) {
849+
$this->fail('A RuntimeException should have been raised.');
850+
} catch (RuntimeException $e) {
851851
}
852852
$process->start();
853853
usleep(1000);

src/Symfony/Component/Routing/Generator/UrlGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
229229
$routeHost = '';
230230
foreach ($hostTokens as $token) {
231231
if ('variable' === $token[0]) {
232-
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#', $mergedParams[$token[3]])) {
232+
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#i', $mergedParams[$token[3]])) {
233233
$message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given) to generate a corresponding URL.', $token[3], $name, $token[2], $mergedParams[$token[3]]);
234234

235235
if ($this->strictRequirements) {

src/Symfony/Component/Routing/RouteCompiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static function compile(Route $route)
4646
$result = self::compilePattern($route, $host, true);
4747

4848
$hostVariables = $result['variables'];
49-
$variables = array_merge($variables, $hostVariables);
49+
$variables = $hostVariables;
5050

5151
$hostTokens = $result['tokens'];
5252
$hostRegex = $result['regex'];
@@ -163,7 +163,7 @@ private static function compilePattern(Route $route, $pattern, $isHost)
163163

164164
return array(
165165
'staticPrefix' => 'text' === $tokens[0][0] ? $tokens[0][1] : '',
166-
'regex' => self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'s',
166+
'regex' => self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'s'.($isHost ? 'i' : ''),
167167
'tokens' => array_reverse($tokens),
168168
'variables' => $variables,
169169
);

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function match($pathinfo)
197197

198198
$host = $this->context->getHost();
199199

200-
if (preg_match('#^a\\.example\\.com$#s', $host, $hostMatches)) {
200+
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
201201
// route1
202202
if ($pathinfo === '/route1') {
203203
return array('_route' => 'route1');
@@ -210,23 +210,23 @@ public function match($pathinfo)
210210

211211
}
212212

213-
if (preg_match('#^b\\.example\\.com$#s', $host, $hostMatches)) {
213+
if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) {
214214
// route3
215215
if ($pathinfo === '/c2/route3') {
216216
return array('_route' => 'route3');
217217
}
218218

219219
}
220220

221-
if (preg_match('#^a\\.example\\.com$#s', $host, $hostMatches)) {
221+
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
222222
// route4
223223
if ($pathinfo === '/route4') {
224224
return array('_route' => 'route4');
225225
}
226226

227227
}
228228

229-
if (preg_match('#^c\\.example\\.com$#s', $host, $hostMatches)) {
229+
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
230230
// route5
231231
if ($pathinfo === '/route5') {
232232
return array('_route' => 'route5');
@@ -239,7 +239,7 @@ public function match($pathinfo)
239239
return array('_route' => 'route6');
240240
}
241241

242-
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#s', $host, $hostMatches)) {
242+
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) {
243243
if (0 === strpos($pathinfo, '/route1')) {
244244
// route11
245245
if ($pathinfo === '/route11') {
@@ -265,7 +265,7 @@ public function match($pathinfo)
265265

266266
}
267267

268-
if (preg_match('#^c\\.example\\.com$#s', $host, $hostMatches)) {
268+
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
269269
// route15
270270
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
271271
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function match($pathinfo)
209209

210210
$host = $this->context->getHost();
211211

212-
if (preg_match('#^a\\.example\\.com$#s', $host, $hostMatches)) {
212+
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
213213
// route1
214214
if ($pathinfo === '/route1') {
215215
return array('_route' => 'route1');
@@ -222,23 +222,23 @@ public function match($pathinfo)
222222

223223
}
224224

225-
if (preg_match('#^b\\.example\\.com$#s', $host, $hostMatches)) {
225+
if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) {
226226
// route3
227227
if ($pathinfo === '/c2/route3') {
228228
return array('_route' => 'route3');
229229
}
230230

231231
}
232232

233-
if (preg_match('#^a\\.example\\.com$#s', $host, $hostMatches)) {
233+
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
234234
// route4
235235
if ($pathinfo === '/route4') {
236236
return array('_route' => 'route4');
237237
}
238238

239239
}
240240

241-
if (preg_match('#^c\\.example\\.com$#s', $host, $hostMatches)) {
241+
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
242242
// route5
243243
if ($pathinfo === '/route5') {
244244
return array('_route' => 'route5');
@@ -251,7 +251,7 @@ public function match($pathinfo)
251251
return array('_route' => 'route6');
252252
}
253253

254-
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#s', $host, $hostMatches)) {
254+
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) {
255255
if (0 === strpos($pathinfo, '/route1')) {
256256
// route11
257257
if ($pathinfo === '/route11') {
@@ -277,7 +277,7 @@ public function match($pathinfo)
277277

278278
}
279279

280-
if (preg_match('#^c\\.example\\.com$#s', $host, $hostMatches)) {
280+
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
281281
// route15
282282
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
283283
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());

src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,13 @@ public function testUrlWithInvalidParameterInHostInNonStrictMode()
461461
$this->assertNull($generator->generate('test', array('foo' => 'baz'), false));
462462
}
463463

464+
public function testHostIsCaseInsensitive()
465+
{
466+
$routes = $this->getRoutes('test', new Route('/', array(), array('locale' => 'en|de|fr'), array(), '{locale}.FooBar.com'));
467+
$generator = $this->getGenerator($routes);
468+
$this->assertSame('//EN.FooBar.com/app.php/', $generator->generate('test', array('locale' => 'EN'), UrlGeneratorInterface::NETWORK_PATH));
469+
}
470+
464471
public function testGenerateNetworkPathBC()
465472
{
466473
$routes = $this->getRoutes('test', new Route('/{name}', array(), array('_scheme' => 'http'), array(), '{locale}.example.com'));

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,25 @@ public function testWithOutHostHostDoesNotMatch()
405405
$matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'example.com'));
406406
$matcher->match('/foo/bar');
407407
}
408+
409+
/**
410+
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
411+
*/
412+
public function testPathIsCaseSensitive()
413+
{
414+
$coll = new RouteCollection();
415+
$coll->add('foo', new Route('/locale', array(), array('locale' => 'EN|FR|DE')));
416+
417+
$matcher = new UrlMatcher($coll, new RequestContext());
418+
$matcher->match('/en');
419+
}
420+
421+
public function testHostIsCaseInsensitive()
422+
{
423+
$coll = new RouteCollection();
424+
$coll->add('foo', new Route('/', array(), array('locale' => 'EN|FR|DE'), array(), '{locale}.example.com'));
425+
426+
$matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com'));
427+
$this->assertEquals(array('_route' => 'foo', 'locale' => 'en'), $matcher->match('/'));
428+
}
408429
}

0 commit comments

Comments
 (0)
0