mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Fix valid filename and length
This commit is contained in:
parent
eef14ecf06
commit
7fffa19fa9
@ -64,6 +64,11 @@ class Fenom
|
||||
|
||||
public static $charset = "UTF-8";
|
||||
|
||||
/**
|
||||
* @var int maximum length of compiled filename (use sha1 of name if bigger)
|
||||
*/
|
||||
public static $filename_length = 200;
|
||||
|
||||
/**
|
||||
* @var int[] of possible options, as associative array
|
||||
* @see setOptions
|
||||
@ -1075,13 +1080,17 @@ class Fenom
|
||||
if (is_array($tpl)) {
|
||||
$hash = implode(".", $tpl) . ":" . $options;
|
||||
foreach ($tpl as &$t) {
|
||||
$t = str_replace(":", "_", basename($t));
|
||||
$t = urlencode(str_replace(":", "_", basename($t)));
|
||||
}
|
||||
return $this->_compile_id . implode("~", $tpl) . "." . sprintf("%x.%x.php", crc32($hash), strlen($hash));
|
||||
$tpl = implode("~", $tpl);
|
||||
} else {
|
||||
$hash = $tpl . ":" . $options;
|
||||
return sprintf($this->_compile_id . "%s.%x.%x.php", str_replace(":", "_", basename($tpl)), crc32($hash), strlen($hash));
|
||||
$tpl = urlencode(str_replace(":", "_", basename($tpl)));
|
||||
}
|
||||
if($tpl > self::$filename_length) {
|
||||
$tpl = sha1($tpl);
|
||||
}
|
||||
return $this->_compile_id . $tpl . "." . sprintf("%x.%x.php", crc32($hash), strlen($hash));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1129,27 +1129,6 @@ class TemplateTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group sb
|
||||
*/
|
||||
public function _testSandbox()
|
||||
{
|
||||
try {
|
||||
var_dump(
|
||||
$this->fenom->compileCode(
|
||||
'{Fenom\Helper::method()->page->title}'
|
||||
)->getBody()
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
print_r($e->getMessage() . "\n" . $e->getTraceAsString());
|
||||
while ($e->getPrevious()) {
|
||||
$e = $e->getPrevious();
|
||||
print_r("\n\n" . $e->getMessage() . " in {$e->getFile()}:{$e->getLine()}\n" . $e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerScalars
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user