File tree 2 files changed +18
-5
lines changed
src/Symfony/Component/Form
Extension/Core/EventListener
Tests/Extension/Core/EventListener
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)
38
38
{
39
39
$ data = $ event ->getData ();
40
40
41
- if ($ this ->defaultProtocol && $ data && ! preg_match ( ' ~^\w+ ://~ ' , $ data ) ) {
41
+ if ($ this ->defaultProtocol && $ data && strpos ( $ data , ' :// ' ) < 1 ) {
42
42
$ event ->setData ($ this ->defaultProtocol .':// ' .$ data );
43
43
}
44
8000
code>
44
}
Original file line number Diff line number Diff line change @@ -40,15 +40,28 @@ public function testSkipKnownUrl()
40
40
$ this ->assertEquals ('http://www.symfony.com ' , $ event ->getData ());
41
41
}
42
42
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 )
44
58
{
45
- $ data = 'ftp://www.symfony.com ' ;
46
59
$ form = $ this ->getMock ('Symfony\Component\Form\Test\FormInterface ' );
47
- $ event = new FormEvent ($ form , $ data );
60
+ $ event = new FormEvent ($ form , $ url );
48
61
49
62
$ filter = new FixUrlProtocolListener ('http ' );
50
63
$ filter ->onSubmit ($ event );
51
64
52
- $ this ->assertEquals (' ftp://www.symfony.com ' , $ event ->getData ());
65
+ $ this ->assertEquals ($ url , $ event ->getData ());
53
66
}
54
67
}
You can’t perform that action at this time.
0 commit comments