First, thanks for making Latte! ☕
While migrating to Latte 2.4 I've find the following issue, if I do this in a presenter:
$this->createTemplate()->setFile('../../foo/bar.latte);
and there's
in bar.latte, rendering fails with
_RuntimeException: Missing template file foo/waldo.latte_
I've tracked it down to an issue in Latte\Loaders\FileLoader::normalizePath() where in the first foreach iteration when $res is still empty then if it hits $part === '..' condition then the $part is just thrown away because it tries to array_pop from an empty array.
The issue can be demonstrated by adding
Assert::same('../../tests', $loader->getReferredName('../tests', '../file'));
to Loaders.FileLoader.phpt.
Hope this is at least a bit understandable.
The workaround is to never pass leading ../ to setFile() (and use realpath() to remove these) but since I've already spent quite a while figuring out where's the problem, the proposed fix is an incoming pull request.
First, thanks for making Latte! ☕
While migrating to Latte 2.4 I've find the following issue, if I do this in a presenter:
and there's
in
bar.latte, rendering fails with_RuntimeException: Missing template file foo/waldo.latte_
I've tracked it down to an issue in
Latte\Loaders\FileLoader::normalizePath()where in the firstforeachiteration when$resis still empty then if it hits$part === '..'condition then the$partis just thrown away because it tries toarray_popfrom an empty array.The issue can be demonstrated by adding
to Loaders.FileLoader.phpt.
Hope this is at least a bit understandable.
The workaround is to never pass leading
../tosetFile()(and userealpath()to remove these) but since I've already spent quite a while figuring out where's the problem, the proposed fix is an incoming pull request.