건국 등 문자열 입력 변경

This commit is contained in:
2018-06-25 00:46:07 +09:00
parent ba3accd834
commit 3d9f38f1e3
2 changed files with 21 additions and 16 deletions
+18 -1
View File
@@ -143,13 +143,30 @@ class StringUtil
return static::padString($str, $maxsize, $ch, 0);
}
public static function escapeTag($str)
public static function escapeTag(?string $str):string
{
if(!$str){
return '';
}
$str = htmlspecialchars($str);
$str = str_replace(["\r\n", "\r", "\n"], '<br>', $str);
return $str;
}
public static function neutralize(?string $str, ?int $maxLen = null){
if(!$str){
return '';
}
if($maxLen && $maxLen > 0){
$str = StringUtil::subStringForWidth($str, 0, $maxLen);
}
$str = htmlspecialchars($str);
$str = StringUtil::removeSpecialCharacter($str);
$str = WebUtil::htmlPurify($str);
$str = StringUtil::textStrip($str);
return $str;
}
public static function textStrip(?string $str):string{
if(!$str){
return '';