8000 Merge branch '3.4' into 4.4 · simPod/symfony@d0b7445 · GitHub
[go: up one dir, main page]

Skip to content

Commit d0b7445

Browse files
Merge branch '3.4' into 4.4
* 3.4: [Yaml] fix dumping strings containing CRs [DI] Fix XmlFileLoader bad error message Tweak message improve PlaintextPasswordEncoder docBlock summary [Validator] Add two missing translations for the Arabic (ar) locale Use some PHP 5.4 constants unconditionally Revert "bug symfony#28179 [DomCrawler] Skip disabled fields processing in Form" Add Spanish translation Fix typo [Validator] add Japanese translation Fix typo Add Polish translation [SecurityBundle] Minor fixes in configuration tree builder bumped Symfony version to 3.4.39 updated VERSION for 3.4.38 update CONTRIBUTORS for 3.4.38 updated CHANGELOG for 3.4.38
2 parents 14b825b + bdd66aa commit d0b7445

File tree

18 files changed

+228
-88
lines changed

18 files changed

+228
-88
lines changed

CONTRIBUTORS.md

Lines changed: 114 additions & 64 deletions
Large diffs are not rendered by default.

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ public function humanize($text)
248248
public function formEncodeCurrency($text, $widget = '')
249249
{
250250
if ('UTF-8' === $charset = $this->getCharset()) {
251-
$text = htmlspecialchars($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
251+
$text = htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
252252
} else {
253-
$text = htmlentities($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
253+
$text = htmlentities($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
254254
$text = iconv('UTF-8', $charset, $text);
255255
$widget = iconv('UTF-8', $charset, $widget);
256256
}

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function addConfiguration(NodeDefinition $node)
141141
->end()
142142
->prototype('scalar')->end()
143143
->end()
144-
->scalarNode('catch_exceptions')->defaultTrue()->end()
144+
->booleanNode('catch_exceptions')->defaultTrue()->end()
145145
;
146146

147147
foreach ($this->options as $name => $value) {
@@ -151,6 +151,8 @@ public function addConfiguration(NodeDefinition $node)
151151
$builder->enumNode($name)->values([null, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT, Cookie::SAMESITE_NONE])->defaultValue($value);
152152
} elseif (\is_bool($value)) {
153153
$builder->booleanNode($name)->defaultValue($value);
154+
} elseif (\is_int($value)) {
155+
$builder->integerNode($name)->defaultValue($value);
154156
} else {
155157
$builder->scalarNode($name)->defaultValue($value);
156158
}

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/LdapFactory.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ public function getKey()
4848
public function addConfiguration(NodeDefinition $node)
4949
{
5050
$node
51+
->fixXmlConfig('default_role')
5152
->children()
5253
->scalarNode('service')->isRequired()->cannotBeEmpty()->defaultValue('ldap')->end()
5354
->scalarNode('base_dn')->isRequired()->cannotBeEmpty()->end()
54-
->scalarNode('search_dn')->end()
55-
->scalarNode('search_password')->end()
55+
->scalarNode('search_dn')->defaultNull()->end()
56+
->scalarNode('search_password')->defaultNull()->end()
5657
->arrayNode('extra_fields')
5758
->prototype('scalar')->end()
5859
->end()

src/Symfony/Component/Config/Tests/Fixtures/Util/not_readable.xml

Whitespace-only changes.

src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,31 @@ public function testLoadFile()
2020
{
2121
$fixtures = __DIR__.'/../Fixtures/Util/';
2222

23+
try {
24+
XmlUtils::loadFile($fixtures);
25+
$this->fail();
26+
} catch (\InvalidArgumentException $e) {
27+
$this->assertStringContainsString('is not a file', $e->getMessage());
28+
}
29+
30+
try {
31+
XmlUtils::loadFile($fixtures.'non_existing.xml');
32+
$this->fail();
33+
} catch (\InvalidArgumentException $e) {
34+
$this->assertStringContainsString('is not a file', $e->getMessage());
35+
}
36+
37+
try {
38+
if ('\\' === \DIRECTORY_SEPARATOR) {
39+
$this->markTestSkipped('chmod is not supported on Windows');
40+
}
41+
chmod($fixtures.'not_readable.xml', 000);
42+
XmlUtils::loadFile($fixtures.'not_readable.xml');
43+
$this->fail();
44+
} catch (\InvalidArgumentException $e) {
45+
$this->assertStringContainsString('is not readable', $e->getMessage());
46+
}
47+
2348
try {
2449
XmlUtils::loadFile($fixtures.'invalid.xml');
2550
$this->fail();
@@ -165,7 +190,7 @@ public function testLoadEmptyXmlFile()
165190
$file = __DIR__.'/../Fixtures/foo.xml';
166191

167192
$this->expectException('InvalidArgumentException');
168-
$this->expectExceptionMessage(sprintf('File %s does not contain valid XML, it is empty.', $file));
193+
$this->expectExceptionMessage(sprintf('File "%s" does not contain valid XML, it is empty.', $file));
169194

170195
XmlUtils::loadFile($file);
171196
}
@@ -186,7 +211,7 @@ public function testLoadWrongEmptyXMLWithErrorHandler()
186211
XmlUtils::loadFile($file);
187212
$this->fail('An exception should have been raised');
188213
} catch (\InvalidArgumentException $e) {
189-
$this->assertEquals(sprintf('File %s does not contain valid XML, it is empty.', $file), $e->getMessage());
214+
$this->assertEquals(sprintf('File "%s" does not contain valid XML, it is empty.', $file), $e->getMessage());
190215
}
191216
} finally {
192217
restore_error_handler();

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,18 @@ public static function parse($content, $schemaOrCallable = null)
122122
*/
123123
public static function loadFile($file, $schemaOrCallable = null)
124124
{
125+
if (!is_file($file)) {
126+
throw new \InvalidArgumentException(sprintf('Resource "%s" is not a file.', $file));
127+
}
128+
129+
if (!is_readable($file)) {
130+
throw new \InvalidArgumentException(sprintf('File "%s" is not readable.', $file));
131+
}
132+
125133
$content = @file_get_contents($file);
134+
126135
if ('' === trim($content)) {
127-
throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));
136+
throw new \InvalidArgumentException(sprintf('File "%s" does not contain valid XML, it is empty.', $file));
128137
}
129138

130139
try {

src/Symfony/Component/DomCrawler/Form.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ public function getValues()
8989
{
9090
$values = [];
9191
foreach ($this->fields->all() as $name => $field) {
92+
if ($field->isDisabled()) {
93+
continue;
94+
}
95+
9296
if (!$field instanceof Field\FileFormField && $field->hasValue()) {
9397
$values[$name] = $field->getValue();
9498
}
@@ -111,6 +115,10 @@ public function getFiles()
111115
$files = [];
112116

113117
foreach ($this->fields->all() as $name => $field) {
118+
if ($field->isDisabled()) {
119+
continue;
120+
}
121+
114122
if ($field instanceof Field\FileFormField) {
115123
$files[$name] = $field->getValue();
116124
}
@@ -465,7 +473,7 @@ private function initialize()
465473

466474
private function addField(\DOMElement $node)
467475
{
468-
if (!$node->hasAttribute('name') || !$node->getAttribute('name') || $node->hasAttribute('disabled')) {
476+
if (!$node->hasAttribute('name') || !$node->getAttribute('name')) {
469477
return;
470478
}
471479

src/Symfony/Component/DomCrawler/Tests/FormTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ public function testConstructorHandlesFormValues()
159159
public function testMultiValuedFields()
160160
{
161161
$form = $this->createForm('<form>
162-
<input type="text" name="foo[4]" value="foo" />
163-
<input type="text" name="foo" value="foo" />
164-
<input type="text" name="foo[2]" value="foo" />
165-
<input type="text" name="foo[]" value="foo" />
166-
<input type="text" name="bar[foo][]" value="foo" />
167-
<input type="text" name="bar[foo][foobar]" value="foo" />
162+
<input type="text" name="foo[4]" value="foo" disabled="disabled" />
163+
<input type="text" name="foo" value="foo" disabled="disabled" />
164+
<input type="text" name="foo[2]" value="foo" disabled="disabled" />
165+
<input type="text" name="foo[]" value="foo" disabled="disabled" />
166+
<input type="text" name="bar[foo][]" value="foo" disabled="disabled" />
167+
<input type="text" name="bar[foo][foobar]" value="foo" disabled="disabled" />
168168
<input type="submit" />
169169
</form>
170170
');
@@ -227,10 +227,10 @@ public function provideInitializeValues()
227227
[],
228228
],
229229
[
230-
'skips disabled input fields',
230+
'takes into account disabled input fields',
231231
'<input type="text" name="foo" value="foo" disabled="disabled" />
232232
<input type="submit" />',
233-
[],
233+
['foo' => ['InputFormField', 'foo']],
234234
],
235235
[
236236
'appends the submitted button value',

src/Symfony/Component/Form/FormRenderer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ public function humanize($text)
293293
public function encodeCurrency(Environment $environment, string $text, string $widget = ''): string
294294
{
295295
if ('UTF-8' === $charset = $environment->getCharset()) {
296-
$text = htmlspecialchars($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
296+
$text = htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
297297
} else {
298-
$text = htmlentities($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
298+
$text = htmlentities($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
299299
$text = iconv('UTF-8', $charset, $text);
300300
$widget = iconv('UTF-8', $charset, $widget);
301301
}

src/Symfony/Component/Security/Core/Encoder/PlaintextPasswordEncoder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1515

1616
/**
17-
* PlaintextPasswordEncoder does not do any encoding.
17+
* PlaintextPasswordEncoder does not do any encoding but is useful in testing environments.
18+
*
19+
* As this encoder is not cryptographically secure, usage of it in production environments is discouraged.
1820
*
1921
* @author Fabien Potencier <fabien@symfony.com>
2022
*/

src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,14 @@
366366
<source>This value should be between {{ min }} and {{ max }}.</source>
367367
<target>يجب أن تكون هذه القيمة بين {{ min }} و {{ max }}.</target>
368368
</trans-unit>
369+
<trans-unit id="95">
370+
<source>This value is not a valid hostname.</source>
371+
<target>هذه القيمة ليست اسم مضيف صالح.</target>
372+
</trans-unit>
373+
<trans-unit id="96">
374+
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375+
<target>يجب أن يكون عدد العناصر في هذه المجموعة مضاعف {{ compared_value }}.</target>
376+
</trans-unit>
369377
</body>
370378
</file>
371379
</xliff>

src/Symfony/Component/Validator/Resources/translations/validators.es.xlf

Copy file name to clipboard
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,15 @@
364364
</trans-unit>
365365
<trans-unit id="94">
366366
<source>This value should be between {{ min }} and {{ max }}.</source>
367-
<target>Este valor debe estar entre {{ min }} y {{ max }}.</target>
367+
<target>Este valor debería estar entre {{ min }} y {{ max }}.</target>
368+
</trans-unit>
369+
<trans-unit id="95">
370+
<source>This value is not a valid hostname.</source>
371+
<target>Este valor no es un nombre de host válido.</target>
372+
</trans-unit>
373+
<trans-unit id="96">
374+
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375+
<target>El número de elementos en esta colección debería ser múltiplo de {{ compared_value }}.</target>
368376
</trans-unit>
369377
</body>
370378
</file>

src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,14 @@
366366
<source>This value should be between {{ min }} and {{ max }}.</source>
367367
<target>{{ min }}以上{{ max }}以下でなければなりません。</target>
368368
</trans-unit>
369+
<trans-unit id="95">
370+
<source>This value is not a valid hostname.</source>
371+
<target>有効なホスト名ではありません。</target>
372+
</trans-unit>
373+
<trans-unit id="96">
374+
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375+
<target>要素の数は{{ compared_value }}の倍数でなければなりません。</target>
376+
</trans-unit>
369377
</body>
370378
</file>
371379
</xliff>

src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@
370370
<source>This value is not a valid hostname.</source>
371371
<target>Ta wartość nie jest prawidłową nazwą hosta.</target>
372372
</trans-unit>
373+
<trans-unit id="96">
374+
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375+
<target>Liczba elementów w tym zbiorze powinna być wielokrotnością {{ compared_value }}.</target>
376+
</trans-unit>
373377
</body>
374378
</file>
375379
</xliff>

src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@
372372
</trans-unit>
373373
<trans-unit id="96">
374374
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375-
<target>Số lượng các phần tử trong bộ sưu tập này nên là bội số của {{compared_value}}.</target>
375+
<target>Số lượng các phần tử trong bộ sưu tập này nên là bội số của {{ compared_value }}.</target>
376376
</trans-unit>
377377
</body>
378378
</file>

src/Symfony/Component/Yaml/Dumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0):
6464
$dumpAsMap = Inline::isHash($input);
6565

6666
foreach ($input as $key => $value) {
67-
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r\n")) {
67+
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r")) {
6868
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
6969
// http://www.yaml.org/spec/1.2/spec.html#id2793979
7070
$blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : '';

src/Symfony/Component/Yaml/Tests/DumperTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,11 +547,26 @@ public function testDumpMultiLineStringAsScalarBlockWhenFirstLineHasLeadingSpace
547547
$this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
548548
}
549549

550-
public function testCarriageReturnIsMaintainedWhenDumpingAsMultiLineLiteralBlock()
550+
public function testCarriageReturnFollowedByNewlineIsMaintainedWhenDumpingAsMultiLineLiteralBlock()
551551
{
552552
$this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(["a\r\nb\nc"], 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
553553
}
554554

555+
public function testCarriageReturnNotFollowedByNewlineIsPreservedWhenDumpingAsMultiLineLiteralBlock()
556+
{
557+
$expected = <<<'YAML'
558+
parent:
559+
foo: "bar\n\rbaz: qux"
560+
561+
YAML;
562+
563+
$this->assertSame($expected, $this->dumper->dump([
564+
'parent' => [
565+
'foo' => "bar\n\rbaz: qux",
566+
],
567+
], 4, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
568+
}
569+
555570
public function testZeroIndentationThrowsException()
556571
{
557572
$this->expectException('InvalidArgumentException');

0 commit comments

Comments
 (0)
0