Remove UTF-8 BOM and CRLF in templates when compiling them

This commit is contained in:
Kijin Sung 2023-09-05 01:05:53 +09:00
parent 55d3dd047c
commit a50041007d
2 changed files with 4 additions and 1 deletions

View file

@ -286,6 +286,9 @@ class TemplateHandler
// detect existence of autoescape config
$this->config->autoescape = (strpos($buff, ' autoescape="') === false) ? null : false;
// remove UTF-8 BOM and convert CRLF to LF
$buff = preg_replace(['/^\xEF\xBB\xBF/', '/\r\n/'], ['', "\n"], $buff);
// replace comments
$buff = preg_replace('@<!--//.*?-->@s', '', $buff);