일부 특수문자가 mysql charset 이 uft8 인 경우 기록이 안되는 현상 수정

This commit is contained in:
thisgun
2024-11-21 11:58:55 +09:00
parent d65fa99e3c
commit 8893b112fa
2 changed files with 24 additions and 0 deletions

View File

@ -31,6 +31,9 @@ $wr_subject = '';
if (isset($_POST['wr_subject'])) {
$wr_subject = substr(trim($_POST['wr_subject']),0,255);
$wr_subject = preg_replace("#[\\\]+$#", "", $wr_subject);
if (function_exists('normalize_utf8_string')) {
$wr_subject = normalize_utf8_string($wr_subject);
}
}
if ($wr_subject == '') {
$msg[] = '<strong>제목</strong>을 입력하세요.';
@ -40,6 +43,9 @@ $wr_content = '';
if (isset($_POST['wr_content'])) {
$wr_content = substr(trim($_POST['wr_content']),0,65536);
$wr_content = preg_replace("#[\\\]+$#", "", $wr_content);
if (function_exists('normalize_utf8_string')) {
$wr_content = normalize_utf8_string($wr_content);
}
}
if ($wr_content == '') {
$msg[] = '<strong>내용</strong>을 입력하세요.';

View File

@ -2280,6 +2280,24 @@ function _callback_bad_tag_convert($matches){
return "<div class=\"embedx\">보안문제로 인하여 관리자 아이디로는 embed 또는 object 태그를 볼 수 없습니다. 확인하시려면 관리권한이 없는 다른 아이디로 접속하세요.</div>";
}
function normalize_utf8_string($string) {
// utf8mb4 환경과 mb_ord 함수가 지원되지 않는 환경에서는 제외한다.
if (G5_DB_CHARSET === 'utf8mb4' || !function_exists('mb_ord')) {
return $string;
}
// Unicode 특수 문자를 일반 문자로 변환
$normalized = preg_replace_callback('/[\x{1D400}-\x{1D7FF}]/u', '_callback_normalizeString', $string);
return $normalized;
}
function _callback_normalizeString($matches){
$charCode = mb_ord($matches[0], 'UTF-8');
// 변환 테이블에서 일반 문자로 매핑
return chr(($charCode - 0x1D400) % 26 + ord('A'));
}
// 토큰 생성
function _token()
{