merged branch ocubom/fix-absolute-paths-detection (PR #2809)

Commits
-------

600066e [Templating] fixed 'scheme://' not detected as absolute path
e6f2687 [HttpKernel] fixed 'scheme://' not detected as absolute path
b50ac5b [Config] fixed 'scheme://' not detected as absolute path

Discussion
----------

[Config][HttpKernel][Templating] 'scheme://' paths not detected as absolute

Bug fix: yes
Feature addition: no
Backwards compatibility break: no (99%)
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

The method ```isAbsolutePath``` does not detect URL schemes as absolute. This makes imposible the use of wrappers to access remote files or the use of files (mostly configuration or templates) stored on phar archives (uses the scheme ```phar://``` in the path).

Three classes implement this methods: ```Symfony\Component\Config\FileLocator```, ```Symfony\Component\HttpKernel\Util\Filesystem``` and ```Symfony\Component\Templating\Loader\FilesytemLoader```. All are updated. Also includes a new check  on all related tests (```Symfony\Component\HttpKernel\Util\Filesystem``` lacks of test).
This commit is contained in:
Fabien Potencier 2011-12-13 17:41:54 +01:00
commit cfe2640877
5 changed files with 7 additions and 0 deletions

View File

@ -89,6 +89,7 @@ class FileLocator implements FileLocatorInterface
&& $file[1] == ':'
&& ($file[2] == '\\' || $file[2] == '/')
)
|| null !== parse_url($file, PHP_URL_SCHEME)
) {
return true;
}

View File

@ -256,6 +256,7 @@ class Filesystem
&& $file[1] == ':'
&& ($file[2] == '\\' || $file[2] == '/')
)
|| null !== parse_url($file, PHP_URL_SCHEME)
) {
return true;
}

View File

@ -115,6 +115,7 @@ class FilesystemLoader extends Loader
&& $file[1] == ':'
&& ($file[2] == '\\' || $file[2] == '/')
)
|| null !== parse_url($file, PHP_URL_SCHEME)
) {
return true;
}

View File

@ -35,6 +35,8 @@ class FileLocatorTest extends \PHPUnit_Framework_TestCase
array('c:\\\\foo.xml'),
array('c:/foo.xml'),
array('\\server\\foo.xml'),
array('https://server/foo.xml'),
array('phar://server/foo.xml'),
);
}

View File

@ -42,6 +42,8 @@ class FilesystemLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(ProjectTemplateLoader2::isAbsolutePath('c:\\\\foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path');
$this->assertTrue(ProjectTemplateLoader2::isAbsolutePath('c:/foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path');
$this->assertTrue(ProjectTemplateLoader2::isAbsolutePath('\\server\\foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path');
$this->assertTrue(ProjectTemplateLoader2::isAbsolutePath('https://server/foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path');
$this->assertTrue(ProjectTemplateLoader2::isAbsolutePath('phar://server/foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path');
}
public function testLoad()