File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
src/Symfony/Component/Form
Extension/Core/EventListener
Tests/Extension/Core/EventListener Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public function onSubmit(FormEvent $event)
3838 {
3939 $ data = $ event ->getData ();
4040
41- if ($ this ->defaultProtocol && $ data && !preg_match ('~^\w +://~ ' , $ data )) {
41+ if ($ this ->defaultProtocol && $ data && !preg_match ('~^[\w+.-] +://~ ' , $ data )) {
4242 $ event ->setData ($ this ->defaultProtocol .':// ' .$ data );
4343 }
4444 }
Original file line number Diff line number Diff line change @@ -40,15 +40,28 @@ public function testSkipKnownUrl()
4040 $ this ->assertEquals ('http://www.symfony.com ' , $ event ->getData ());
4141 }
4242
43- public function testSkipOtherProtocol ()
43+ public function provideUrlsWithSupportedProtocols ()
44+ {
45+ return array (
46+ array ('ftp://www.symfony.com ' ),
47+ array ('chrome-extension://foo ' ),
48+ array ('h323://foo ' ),
49+ array ('iris.beep://foo ' ),
50+ array ('foo+bar://foo ' ),
51+ );
52+ }
53+
54+ /**
55+ * @dataProvider provideUrlsWithSupportedProtocols
56+ */
57+ public function testSkipOtherProtocol ($ url )
4458 {
45- $ data = 'ftp://www.symfony.com ' ;
4659 $ form = $ this ->getMock ('Symfony\Component\Form\Test\FormInterface ' );
47- $ event = new FormEvent ($ form , $ data );
60+ $ event = new FormEvent ($ form , $ url );
4861
4962 $ filter = new FixUrlProtocolListener ('http ' );
5063 $ filter ->onSubmit ($ event );
5164
52- $ this ->assertEquals (' ftp://www.symfony.com ' , $ event ->getData ());
65+ $ this ->assertEquals ($ url , $ event ->getData ());
5366 }
5467}
You can’t perform that action at this time.
0 commit comments