File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,18 +116,32 @@ function escapeHtml(text: string): string {
116116 return div . innerHTML ;
117117}
118118
119+ /**
120+ * href 속성값을 안전하게 escape
121+ * 따옴표, 꺾쇠괄호 등을 HTML 엔티티로 변환
122+ */
123+ function escapeHtmlAttribute ( value : string ) : string {
124+ return value
125+ . replace ( / & / g, '&' )
126+ . replace ( / " / g, '"' )
127+ . replace ( / ' / g, ''' )
128+ . replace ( / < / g, '<' )
129+ . replace ( / > / g, '>' ) ;
130+ }
131+
119132/**
120133 * Breadcrumb 아이템을 HTML 문자열로 변환
121134 */
122135function renderBreadcrumbItem ( item : BreadcrumbItem , isLast : boolean ) : string {
123136 const escapedName = escapeHtml ( item . name ) ;
137+ const escapedPath = escapeHtmlAttribute ( item . path ) ;
124138
125139 if ( isLast ) {
126140 return `<span class="truncate text-gray-400 dark:text-gray-300">${ escapedName } </span>` ;
127141 }
128142
129143 if ( item . linkable ) {
130- return `<a href="${ item . path } " class="truncate text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 transition-colors">${ escapedName } </a> / ` ;
144+ return `<a href="${ escapedPath } " class="truncate text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 transition-colors">${ escapedName } </a> / ` ;
131145 }
132146
133147 // linkable=false인 항목은 회색으로 표시 (클릭 불가 시각 표시)
You can’t perform that action at this time.
0 commit comments