no type errors with invalid submitted data types
This commit is contained in:
parent
25c2f91877
commit
4217cc1348
@ -36,7 +36,7 @@ class FixUrlProtocolListener implements EventSubscriberInterface
|
|||||||
{
|
{
|
||||||
$data = $event->getData();
|
$data = $event->getData();
|
||||||
|
|
||||||
if ($this->defaultProtocol && $data && !preg_match('~^[\w+.-]+://~', $data)) {
|
if ($this->defaultProtocol && $data && is_string($data) && !preg_match('~^[\w+.-]+://~', $data)) {
|
||||||
$event->setData($this->defaultProtocol.'://'.$data);
|
$event->setData($this->defaultProtocol.'://'.$data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,4 +82,12 @@ class UrlTypeTest extends TextTypeTest
|
|||||||
'default_protocol' => array(),
|
'default_protocol' => array(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSubmitWithNonStringDataDoesNotBreakTheFixUrlProtocolListener()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create(static::TESTED_TYPE);
|
||||||
|
$form->submit(array('domain.com', 'www.domain.com'));
|
||||||
|
|
||||||
|
$this->assertSame(array('domain.com', 'www.domain.com'), $form->getData());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user