Skip to content

Commit 05a1c5f

Browse files
committed
no type errors with invalid submitted data types
1 parent acfd5c5 commit 05a1c5f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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
}

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)