8000 added different protocols to be allowed as asset base_urls · symfony/symfony@ab65ba4 · GitHub
[go: up one dir, main page]

Skip to content

Commit ab65ba4

Browse files
added different protocols to be allowed as asset base_urls
1 parent 68c869b commit ab65ba4

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/Symfony/Component/Asset/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.2.0
5+
-----
6+
7+
* added different protocols to be allowed as asset base_urls
8+
49
3.4.0
510
-----
611

src/Symfony/Component/Asset/Tests/UrlPackageTest.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,28 @@ public function getConfigs()
3333
array('http://example.net', '', 'http://example.com/foo', 'http://example.com/foo'),
3434
array('http://example.net', '', 'https://example.com/foo', 'https://example.com/foo'),
3535
array('http://example.net', '', '//example.com/foo', '//example.com/foo'),
36+
array('file:///example/net', '', 'file:///example/com/foo', 'file:///example/com/foo'),
37+
array('ftp://example.net', '', 'ftp://example.com', 'ftp://example.com'),
3638

3739
array('http://example.com', '', '/foo', 'http://example.com/foo?v1'),
3840
array('http://example.com', '', 'foo', 'http://example.com/foo?v1'),
3941
array('http://example.com/', '', 'foo', 'http://example.com/foo?v1'),
4042
array('http://example.com/foo', '', 'foo', 'http://example.com/foo/foo?v1'),
4143
array('http://example.com/foo/', '', 'foo', 'http://example.com/foo/foo?v1'),
44+
array('file:///example/com/foo/', '', 'foo', 'file:///example/com/foo/foo?v1'),
4245

4346
array(array('http://example.com'), '', '/foo', 'http://example.com/foo?v1'),
4447
array(array('http://example.com', 'http://example.net'), '', '/foo', 'http://example.com/foo?v1'),
4548
array(array('http://example.com', 'http://example.net'), '', '/fooa', 'http://example.net/fooa?v1'),
49+
array(array('file:///example/com', 'file:///example/net'), '', '/foo', 'file:///example/com/foo?v1'),
50+
array(array('ftp://example.com', 'ftp://example.net'), '', '/fooa', 'ftp://example.net/fooa?v1'),
4651

4752
array('http://example.com', 'version-%2$s/%1$s', '/foo', 'http://example.com/version-v1/foo'),
4853
array('http://example.com', 'version-%2$s/%1$s', 'foo', 'http://example.com/version-v1/foo'),
4954
array('http://example.com', 'version-%2$s/%1$s', 'foo/', 'http://example.com/version-v1/foo/'),
5055
array('http://example.com', 'version-%2$s/%1$s', '/foo/', 'http://example.com/version-v1/foo/'),
56+
array('file:///example/com', 'version-%2$s/%1$s', '/foo/', 'file:///example/com/version-v1/foo/'),
57+
array('ftp://example.com', 'version-%2$s/%1$s', '/foo/', 'ftp://example.com/version-v1/foo/'),
5158
);
5259
}
5360

@@ -97,11 +104,21 @@ public function testNoBaseUrls()
97104
}
98105

99106
/**
107+
* @dataProvider getWrongBaseUrlConfig
108+
*
100109
* @expectedException \Symfony\Component\Asset\Exception\InvalidArgumentException
101110
*/
102-
public function testWrongBaseUrl()
111+
public function testWrongBaseUrl($baseUrls)
103112
{
104-
new UrlPackage(array('not-a-url'), new EmptyVersionStrategy());
113+
new UrlPackage($baseUrls, new EmptyVersionStrategy());
114+
}
115+
116+
public function getWrongBaseUrlConfig()
117+
{
118+
return array(
119+
array('not-a-url'),
120+
array('not-a-url-with-query?query=://')
121+
);
105122
}
106123

107124
private function getContext($secure)

src/Symfony/Component/Asset/UrlPackage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private function getSslUrls($urls)
129129
foreach ($urls as $url) {
130130
if ('https://' === substr($url, 0, 8) || '//' === substr($url, 0, 2)) {
131131
$sslUrls[] = $url;
132-
} elseif ('http://' !== substr($url, 0, 7)) {
132+
} elseif (null === parse_url($url, PHP_URL_SCHEME)) {
133133
throw new InvalidArgumentException(sprintf('"%s" is not a valid URL', $url));
134134
}
135135
}

0 commit comments

Comments
 (0)
0