260702_01_ENH: 리스트 작업 도중 공용 ui를 적용하기 위한 중간 커밋
This commit is contained in:
@@ -1,15 +1,28 @@
|
||||
export function sanitizeHtml(input: string): string {
|
||||
if (!input) return "";
|
||||
"use client";
|
||||
|
||||
let s = input.replace(/<\s*script[^>]*>[\s\S]*?<\s*\/\s*script\s*>/gi, "");
|
||||
s = s.replace(/<\s*style[^>]*>[\s\S]*?<\s*\/\s*style\s*>/gi, "");
|
||||
s = s.replace(/\son\w+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, "");
|
||||
s = s.replace(/\s(href|src)\s*=\s*("|')\s*javascript:[^"']*("|')/gi, ' $1="#"');
|
||||
import DOMPurify from "dompurify";
|
||||
|
||||
return s;
|
||||
const HTML_PROFILE = {
|
||||
USE_PROFILES: {
|
||||
html: true,
|
||||
},
|
||||
} as const;
|
||||
|
||||
export function sanitizeHtml(
|
||||
input: string,
|
||||
): string {
|
||||
if (!input) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return DOMPurify.sanitize(
|
||||
input,
|
||||
HTML_PROFILE,
|
||||
);
|
||||
}
|
||||
|
||||
// 기존 코드 호환용
|
||||
export function sanitizeHtmlForPreview(input: string): string {
|
||||
export function sanitizeHtmlForPreview(
|
||||
input: string,
|
||||
): string {
|
||||
return sanitizeHtml(input);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user