-
-
Notifications
You must be signed in to change notification settings - Fork 111
Description
Version: 3.0.18
Bug Description
The internal method of the class FileLoader
protected static function normalizePath(string $path): string
converts all forward slashes in the supplied path to backslashes on Windows before returning:
return implode(DIRECTORY_SEPARATOR, $res);
This is correct for normal canonical paths to files, but doesn't work in the very specific case of files loaded from a PHAR archive.
Their path starts with phar://, such as:
'phar://C:/xampp/htdocs/kraken-control-tester/kraken-control.phar/app/Module/Basic/Presenters/templates/...'
and the method normalizePath will convert this blindly into:
'phar:\\C:\xampp\htdocs\kraken-control-tester\kraken-control.phar\app\Module\Basic\Presenters\templates\....'
Due to this blind conversion, rendering of Latte templates loaded from PHARs on Windows breaks down.
A one-line solution is to convert the :\\ back to correct value:
$res_str = implode(DIRECTORY_SEPARATOR, $res);
return (str_starts_with($res_str, 'phar:') ? str_replace(":\\\\","://", $res_str) : $res_str);
Once this is done, even complicated templates from PHARs are rendering just fine.
I will try to create the appropriate Pull Request.