8000 bug #26621 [Form] no type errors with invalid submitted data types (x… · symfony/symfony@2349e97 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2349e97

Browse files
committed
bug #26621 [Form] no type errors with invalid submitted data types (xabbuh)
This PR was merged into the 2.7 branch. Discussion ---------- [Form] no type errors with invalid submitted data types | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #26557 | License | MIT | Doc PR | Commits ------- 4217cc1 no type errors with invalid submitted data types
2 parents a53205c + 4217cc1 commit 2349e97

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function onSubmit(FormEvent $event)
3636
{
3737
$data = $event->getData();
3838

39-
if ($this->defaultProtocol && $data && !preg_match('~^[\w+.-]+://~', $data)) {
39+
if ($this->defaultProtocol && $data && is_string($data) && !preg_match('~^[\w+.-]+://~', $data)) {
4040
$event->setData($this->defaultProtocol.'://'.$data);
4141
}
4242
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,12 @@ public function testThrowExceptionIfDefaultProtocolIsInvalid()
8282
'default_protocol' => array(),
8383
));
8484
}
85+
86+
public function testSubmitWithNonStringDataDoesNotBreakTheFixUrlProtocolListener()
87+
{
88+
$form = $this->factory->create(static::TESTED_TYPE);
89+
$form->submit(array('domain.com', 'www.domain.com'));
90+
91+
$this->assertSame(array('domain.com', 'www.domain.com'), $form->getData());
92+
}
8593
}

0 commit comments

Comments
 (0)
0