Skip to content

Commit 3ebc24c

Browse files
committed
Fix case-insensitive boolean deserialization
The visitBoolean() method only accepts lowercase "true"/"false" but XML APIs (notably .NET-based services) commonly return "True"/"False".
1 parent b02a6c0 commit 3ebc24c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/XmlDeserializationVisitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function visitBoolean($data, array $type): bool
142142
{
143143
$this->assertValueCanBeCastToString($data);
144144

145-
$data = (string) $data;
145+
$data = strtolower((string) $data);
146146

147147
if ('true' === $data || '1' === $data) {
148148
return true;

tests/Serializer/XmlSerializationTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,16 @@ public function testXMLBooleans($xmlBoolean, $boolean)
7979

8080
public static function getXMLBooleans()
8181
{
82-
return [['true', true], ['false', false], ['1', true], ['0', false]];
82+
return [
83+
['true', true],
84+
['false', false],
85+
['1', true],
86+
['0', false],
87+
['True', true],
88+
['False', false],
89+
['TRUE', true],
90+
['FALSE', false],
91+
];
8392
}
8493

8594
public function testAccessorSetterDeserialization()

0 commit comments

Comments
 (0)