From c7d54e61164e81fe20dd79dec2bc28b21fcd33e6 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sun, 9 Aug 2026 03:30:56 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20[UX=20improvement]=20?= =?UTF-8?q?Add=20generic=20fallback=20for=20empty=20root=20directory=20nam?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .jules/palette.md | 4 ++++ src/main/kotlin/html4tree/main.kt | 6 ++++-- src/test/kotlin/html4tree/MainTest.kt | 12 ++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.jules/palette.md b/.jules/palette.md index 7b223901..41b5bc2b 100644 --- a/.jules/palette.md +++ b/.jules/palette.md @@ -52,3 +52,7 @@ ## 2024-07-13 - 빈 디렉토리 상태의 접근성(Accessibility) 개선 **Learning:** 정적 파일 서버의 빈 디렉토리 상태는 스크린 리더 사용자에게 컨텐츠 누락으로 오해받을 수 있으며, 시각적으로도 일반 리스트 아이템과 정렬이 맞지 않는 문제가 있었습니다. **Action:** 빈 상태를 나타내는 요소에 `role="status"`를 추가하여 스크린 리더가 명확하게 인지할 수 있도록 하고, 아이콘과 flex 레이아웃을 통해 다른 리스트 아이템과 일관된 시각적 흐름을 제공하도록 합니다. + +## 2026-08-09 - 루트 디렉토리 빈 이름 대체(Fallback) 처리 +**Learning:** 파일 시스템 루트(예: `/` 또는 `C:\`)의 경우 `File.getName()`이 빈 문자열을 반환하여, 생성된 HTML에서 빈 ``과 `<h1>` 태그가 만들어집니다. 이는 화면 판독기 사용자에게 페이지 제목이 제공되지 않으므로 접근성을 심각하게 저하시킵니다. +**Action:** 디렉토리 이름이 비어 있는 경우 시각적/접근성 목적으로 포괄적인 대체 텍스트(예: `/`)를 제공하십시오. 정보 유출(Information Disclosure) 취약점을 방지하기 위해 서버의 절대 경로(`absolutePath`)를 사용자에게 노출하는 대체값은 절대 사용하지 마십시오. diff --git a/src/main/kotlin/html4tree/main.kt b/src/main/kotlin/html4tree/main.kt index f52a1468..cb912238 100644 --- a/src/main/kotlin/html4tree/main.kt +++ b/src/main/kotlin/html4tree/main.kt @@ -326,6 +326,8 @@ fun process_dir(curr_dir: File, excludeSet: Set<String>? = null, dirFiles: Array val exclude: Set<String> = excludeSet ?: process_ignore_file(curr_dir) + val dirName = if (curr_dir.name.isEmpty()) "/" else curr_dir.name + val index_top = """<!doctype html> <html lang="ko"> <head> @@ -336,12 +338,12 @@ fun process_dir(curr_dir: File, excludeSet: Set<String>? = null, dirFiles: Array <meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src '${STYLE_HASH}'; base-uri 'none'; form-action 'none';"> <!-- 보안 향상: 리퍼러를 통한 디렉토리 경로 노출 방지 --> <meta name="referrer" content="no-referrer"> - <title>${curr_dir.getName().escapeHtml()} + ${dirName.escapeHtml()}
-

${curr_dir.getName().escapeHtml()}

+

${dirName.escapeHtml()}