php-liquid icon indicating copy to clipboard operation
php-liquid copied to clipboard

Illegal template name

Open asacarter opened this issue 5 years ago • 0 comments

Given the template name page.contact, it will fail if the extensions are set to false.

Maybe it should check if the value after the . is the value of the include suffix?

Or what does it matter if it matches page.contact.liquid or page.contact?

\Liquid\Liquid::set('INCLUDE_SUFFIX', 'liquid');
\Liquid\Liquid::set('INCLUDE_PREFIX', '');
\Liquid\Liquid::set('INCLUDE_ALLOW_EXT', false);
\Liquid\Liquid::set('ESCAPE_BY_DEFAULT', false);

$template_file = 'page.contact'
$liquid->parseFile ($template_file);

FileSystem/local.php

$nameRegex = Liquid::get('INCLUDE_ALLOW_EXT')
	? new Regexp('/^[^.\/][a-zA-Z0-9_\.\/-]+$/')
	: new Regexp('/^[^.\/][a-zA-Z0-9_\/-]+$/');

if (!$nameRegex->match($templatePath)) {
	throw new ParseException("Illegal template name '$templatePath'");
}

asacarter avatar May 11 '19 14:05 asacarter