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 #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
}

0 commit comments

Comments
 (0)