261110_01_ENH: 템플릿 명 최대 128자 확장 및 문자 템플릿 제목 64자 제한

This commit is contained in:
2026-11-10 17:29:47 +09:00
parent 67f17e993d
commit de7018475d
3 changed files with 18 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ package com.kri.notihub.server.common.util;
import static com.kri.notihub.server.common.consts.NotihubConst.SMS_TYPE_CODE_LIST;
import com.kri.common.feature.util.StringUtil;
import com.kri.common.feature.web.BusinessException;
import com.kri.notihub.server.common.enums.SendType;
import com.kri.notihub.server.dto.template.TemplateBasicDto;
import java.nio.charset.StandardCharsets;
@@ -17,6 +18,7 @@ public final class TemplateContentSanitizer {
// 필요 시 시스템 정책에 맞게 조정
// (KOR 환경에서 SMS는 바이트 기준으로 제한을 두는 경우가 흔함)
private static final int SMS_MAX_BYTES_UTF8 = 90;
public static final int SMS_TITLE_MAX_LENGTH = 64;
private static final Pattern ESCAPED_QRCODE_OPEN_TAG_PATTERN =
Pattern.compile("(?i)<\\s*qrcode\\b([\\s\\S]*?)/?\\s*>");
private static final Pattern ESCAPED_QRCODE_CLOSE_TAG_PATTERN =
@@ -80,6 +82,17 @@ public final class TemplateContentSanitizer {
return trimmed.substring(0, end);
}
/**
* 문자 제목은 평문 변환 후 최대 64자(코드포인트 기준)까지만 허용
*/
private static void validateSmsTitleLength(String title) {
if (title != null
&& title.codePointCount(0, title.length()) > SMS_TITLE_MAX_LENGTH) {
throw BusinessException.badRequest("TITLE_TOO_LONG",
"문자 제목은 " + SMS_TITLE_MAX_LENGTH + "자 이하로 입력해야 합니다.");
}
}
/**
* 제어문자 제거(개행/탭은 옵션), 줄바꿈은 \n 으로 통일
*/
@@ -211,7 +224,7 @@ public final class TemplateContentSanitizer {
case SMS, LMS, MMS -> {
// 평문화
outTitle = htmlToPlainTextPreserveNewlines(outTitle);
outTitle = truncateTo128CodePoints(outTitle);
validateSmsTitleLength(outTitle);
outBody = htmlToPlainTextPreserveNewlines(outBody);
}

View File

@@ -34,13 +34,13 @@ public class TemplateBasicDto {
@Schema(description = "템플릿 목적 (0: 일반, 1: 휴대전화번호 인증)")
private TemplatePurpose tmplatPurpose;
@Size(max = 32)
@Size(max = 128)
@NotBlank
@Schema(description = "템플릿 명")
private String tmplatNm;
@Size(max = 128)
@Schema(description = "발송시 제목")
@Schema(description = "발송시 제목 (문자 템플릿은 평문 기준 최대 64자)")
private String tmplatTitle;
@Schema(description = "발송 내용 (알림톡은 외부 상세 조회 결과로 저장)")

View File

@@ -46,9 +46,9 @@ public class TTmplatEntity {
@Column(name = "tmplat_purpose", nullable = false)
private Short tmplatPurpose;
@Size(max = 32)
@Size(max = 128)
@NotNull
@Column(name = "tmplat_nm", nullable = false, length = 32)
@Column(name = "tmplat_nm", nullable = false, length = 128)
private String tmplatNm;
@Size(max = 128)