diff --git a/src/Symfony/Component/Asset/CHANGELOG.md b/src/Symfony/Component/Asset/CHANGELOG.md index bb4c02f333187..1c473dd1e52c1 100644 --- a/src/Symfony/Component/Asset/CHANGELOG.md +++ b/src/Symfony/Component/Asset/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.2.0 +----- + + * added different protocols to be allowed as asset base_urls + 3.4.0 ----- diff --git a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php index d37ba0126c5a0..ff6d5f49ec1e0 100644 --- a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php @@ -33,21 +33,28 @@ public function getConfigs() array('http://example.net', '', 'http://example.com/foo', 'http://example.com/foo'), array('http://example.net', '', 'https://example.com/foo', 'https://example.com/foo'), array('http://example.net', '', '//example.com/foo', '//example.com/foo'), + array('file:///example/net', '', 'file:///example/com/foo', 'file:///example/com/foo'), + array('ftp://example.net', '', 'ftp://example.com', 'ftp://example.com'), array('http://example.com', '', '/foo', 'http://example.com/foo?v1'), array('http://example.com', '', 'foo', 'http://example.com/foo?v1'), array('http://example.com/', '', 'foo', 'http://example.com/foo?v1'), array('http://example.com/foo', '', 'foo', 'http://example.com/foo/foo?v1'), array('http://example.com/foo/', '', 'foo', 'http://example.com/foo/foo?v1'), + array('file:///example/com/foo/', '', 'foo', 'file:///example/com/foo/foo?v1'), array(array('http://example.com'), '', '/foo', 'http://example.com/foo?v1'), array(array('http://example.com', 'http://example.net'), '', '/foo', 'http://example.com/foo?v1'), array(array('http://example.com', 'http://example.net'), '', '/fooa', 'http://example.net/fooa?v1'), + array(array('file:///example/com', 'file:///example/net'), '', '/foo', 'file:///example/com/foo?v1'), + array(array('ftp://example.com', 'ftp://example.net'), '', '/fooa', 'ftp://example.net/fooa?v1'), array('http://example.com', 'version-%2$s/%1$s', '/foo', 'http://example.com/version-v1/foo'), array('http://example.com', 'version-%2$s/%1$s', 'foo', 'http://example.com/version-v1/foo'), array('http://example.com', 'version-%2$s/%1$s', 'foo/', 'http://example.com/version-v1/foo/'), array('http://example.com', 'version-%2$s/%1$s', '/foo/', 'http://example.com/version-v1/foo/'), + array('file:///example/com', 'version-%2$s/%1$s', '/foo/', 'file:///example/com/version-v1/foo/'), + array('ftp://example.com', 'version-%2$s/%1$s', '/foo/', 'ftp://example.com/version-v1/foo/'), ); } @@ -97,11 +104,21 @@ public function testNoBaseUrls() } /** + * @dataProvider getWrongBaseUrlConfig + * * @expectedException \Symfony\Component\Asset\Exception\InvalidArgumentException */ - public function testWrongBaseUrl() + public function testWrongBaseUrl($baseUrls) { - new UrlPackage(array('not-a-url'), new EmptyVersionStrategy()); + new UrlPackage($baseUrls, new EmptyVersionStrategy()); + } + + public function getWrongBaseUrlConfig() + { + return array( + array('not-a-url'), + array('not-a-url-with-query?query=://'), + ); } private function getContext($secure) diff --git a/src/Symfony/Component/Asset/UrlPackage.php b/src/Symfony/Component/Asset/UrlPackage.php index 77055e43db372..b9f91237d9070 100644 --- a/src/Symfony/Component/Asset/UrlPackage.php +++ b/src/Symfony/Component/Asset/UrlPackage.php @@ -129,7 +129,7 @@ private function getSslUrls($urls) foreach ($urls as $url) { if ('https://' === substr($url, 0, 8) || '//' === substr($url, 0, 2)) { $sslUrls[] = $url; - } elseif ('http://' !== substr($url, 0, 7)) { + } elseif (null === parse_url($url, PHP_URL_SCHEME)) { throw new InvalidArgumentException(sprintf('"%s" is not a valid URL', $url)); } }