Skip to content

Commit 8c95956

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: fix tests Drop test case Catch TableNotFoundException in MySQL delete [DoctrineBridge] Fix deprecation warning with ORM 3 when guessing field lengths Throw TransformationFailedException when there is a null bytes injection [Cache][Lock] Identify missing table in pgsql correctly and address failing integration tests [Serializer] Fix object normalizer when properties has the same name as their accessor
2 parents c72cf9a + 42b27ad commit 8c95956

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

Extension/Core/DataTransformer/DateTimeToStringTransformer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ public function reverseTransform(mixed $value): ?\DateTime
109109
throw new TransformationFailedException('Expected a string.');
110110
}
111111

112+
if (str_contains($value, "\0")) {
113+
throw new TransformationFailedException('Null bytes not allowed');
114+
}
115+
112116
$outputTz = new \DateTimeZone($this->outputTimezone);
113117
$dateTime = \DateTime::createFromFormat($this->parseFormat, $value, $outputTz);
114118

Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,19 @@ public function testReverseTransformEmpty()
133133
$this->assertNull($reverseTransformer->reverseTransform(''));
134134
}
135135

136+
public function testReverseTransformWithNullBytes()
137+
{
138+
$transformer = new DateTimeToStringTransformer();
139+
140+
$nullByte = \chr(0);
141+
$value = '2024-03-15 21:11:00'.$nullByte;
142+
143+
$this->expectException(TransformationFailedException::class);
144+
$this->expectExceptionMessage('Null bytes not allowed');
145+
146+
$transformer->reverseTransform($value);
147+
}
148+
136149
public function testReverseTransformWithDifferentTimezones()
137150
{
138151
$reverseTransformer = new DateTimeToStringTransformer('America/New_York', 'Asia/Hong_Kong', 'Y-m-d H:i:s');

Tests/Extension/Core/Type/BaseTypeTestCase.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ public function testPassIdAndNameToView()
4040
$this->assertEquals('name', $view->vars['full_name']);
4141
}
4242

43-
public function testStripLeadingUnderscoresAndDigitsFromId()
44-
{
45-
$view = $this->factory->createNamed('_09name', $this->getTestedType(), null, $this->getTestOptions())
46-
->createView();
47-
48-
$this->assertEquals('name', $view->vars['id']);
49-
$this->assertEquals('_09name', $view->vars['name']);
50-
$this->assertEquals('_09name', $view->vars['full_name']);
51-
}
52-
5343
public function testPassIdAndNameToViewWithParent()
5444
{
5545
$view = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE)

0 commit comments

Comments
 (0)