Fix autoescape problems

- 삼항식 사용시 autoescape 우선순위가 꼬이는 문제 수정
- $lang 변수는 autoescape하지 않도록 변경
- ENT_COMPAT을 ENT_QUOTES로 변경 (자바스크립트에서 사용시 '홑따옴표' 이탈 방지)
This commit is contained in:
Kijin Sung 2018-10-10 14:43:43 +09:00
parent 254b83dfd7
commit 6abd345dcf

View file

@ -557,6 +557,10 @@ class TemplateHandler
{
$escape_option = 'noescape';
}
elseif(preg_match('/^\$(?:user_)?lang->[a-zA-Z0-9\_]+$/', $m[1]))
{
$escape_option = 'noescape';
}
else
{
$escape_option = $this->config->autoescape !== null ? 'auto' : 'noescape';
@ -894,14 +898,14 @@ class TemplateHandler
switch($escape_option)
{
case 'escape':
return "htmlspecialchars({$str}, ENT_COMPAT, 'UTF-8', true)";
return "htmlspecialchars({$str}, ENT_QUOTES, 'UTF-8', true)";
case 'noescape':
return "{$str}";
case 'autoescape':
return "htmlspecialchars({$str}, ENT_COMPAT, 'UTF-8', false)";
return "htmlspecialchars({$str}, ENT_QUOTES, 'UTF-8', false)";
case 'auto':
default:
return "(\$this->config->autoescape === 'on' ? htmlspecialchars({$str}, ENT_COMPAT, 'UTF-8', false) : {$str})";
return "(\$this->config->autoescape === 'on' ? htmlspecialchars({$str}, ENT_QUOTES, 'UTF-8', false) : ({$str}))";
}
}