diff --git a/frontend/src/lib/utils/docMarkdown.ts b/frontend/src/lib/utils/docMarkdown.ts index 9af6d30..cbf7173 100644 --- a/frontend/src/lib/utils/docMarkdown.ts +++ b/frontend/src/lib/utils/docMarkdown.ts @@ -65,6 +65,19 @@ docMarked.use({ `` ); }, + // 외부 링크(http/https) → 새 탭 + rel=noopener noreferrer (탭내빙 차단). 521건 실재. + // 내부/프래그먼트/상대 링크는 손대지 않음 — `#` anchor 는 gfmHeadingId/outline 경로 유지 + // (클릭 인터셉터 없음 → 충돌 0), 상대 .md(코퍼스 0건)는 기본 동작(inert). marked 15 토큰객체 시그니처. + link(token: any): string { + const href = (token?.href ?? '') as string; + const text = this.parser.parseInline(token?.tokens ?? []); + const titleAttr = token?.title ? ` title="${escAttr(token.title as string)}"` : ''; + const safeHref = escAttr(href); + if (/^https?:\/\//i.test(href)) { + return `${text}`; + } + return `${text}`; + }, }, }); @@ -82,6 +95,8 @@ const SANITIZE_OPTS = { 'data-md-image-internal', 'data-md-image-alt', 'loading', + 'target', + 'rel', ], ADD_TAGS: ['figure', 'figcaption'], FORBID_TAGS: ['script', 'iframe', 'object', 'embed', 'link', 'meta'],