-
-
Notifications
You must be signed in to change notification settings - Fork 111
Description
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
{include waldo.latte}
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'));
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.