made it possible to store templates with vfsStream

This commit is contained in:
Fabien Potencier
2016-10-12 19:34:58 -07:00
parent 3879038edc
commit 4d607583ff
2 changed files with 3 additions and 2 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.26.2 (2016-XX-XX)
* Fixed template paths when a template name contains a protocol like vfs://
* improved debugging with Twig_Sandbox_SecurityError exceptions for disallowed methods and properties
* 1.26.1 (2016-10-05)
+2 -2
View File
@@ -257,12 +257,12 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
private function normalizePath($path)
{
$parts = explode('/', str_replace('\\', '/', $path));
$isPhar = strpos($path, 'phar://') === 0;
$hasProto = false !== strpos($path, '://');
$new = array();
foreach ($parts as $i => $part) {
if ('..' === $part) {
array_pop($new);
} elseif ('.' !== $part && ('' !== $part || 0 === $i || $isPhar && $i < 3)) {
} elseif ('.' !== $part && ('' !== $part || 0 === $i || $hasProto && $i < 3)) {
$new[] = $part;
}
}