8000 [Form] PropertyPath now can handle elements with special characters · ivanrey/symfony@e787d5d · GitHub
[go: up one dir, main page]

Skip to content

Commit e787d5d

Browse files
committed
[Form] PropertyPath now can handle elements with special characters
1 parent 4f1ae66 commit e787d5d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Symfony/Component/Form/Util/PropertyPath.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct($propertyPath)
6464
$remaining = $propertyPath;
6565

6666
// first element is evaluated differently - no leading dot for properties
67-
$pattern = '/^((\w+)|\[([^\]]+)\])(.*)/';
67+
$pattern = '/^(([^\.\[]+)|\[([^\]]+)\])(.*)/';
6868

6969
while (preg_match($pattern, $remaining, $matches)) {
7070
if ($matches[2] !== '') {

tests/Symfony/Tests/Component/Form/PropertyPathTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ public function testGetValueReadsIndexWithSpecialChars()
4848
$this->assertEquals('Bernhard', $path->getValue($array));
4949
}
5050

51+
public function testGetValueReadsElementWithSpecialCharsExceptDOt()
52+
{
53+
$array = array('#!@$' => 'Bernhard');
54+
55+
$path = new PropertyPath('#!@$');
56+
57+
$this->assertEquals('Bernhard', $path->getValue($array));
58+
}
59+
5160
public function testGetValueReadsNestedIndexWithSpecialChars()
5261
{
5362
$array = array('root' => array('#!@$.' => 'Bernhard'));

0 commit comments

Comments
 (0)
0