From a6b1e6bafac2687d8177b2ff1dac93bc3209da2a Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Mon, 10 Aug 2026 03:59:53 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Add=20generic=20fallb?= =?UTF-8?q?ack=20text=20for=20root=20directory=20name=20to=20fix=20empty?= =?UTF-8?q?=20title/h1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .jules/palette.md | 3 +++ src/main/kotlin/html4tree/main.kt | 4 ++-- src/test/kotlin/html4tree/MainTest.kt | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.jules/palette.md b/.jules/palette.md index 7b223901..83939280 100644 --- a/.jules/palette.md +++ b/.jules/palette.md @@ -52,3 +52,6 @@ ## 2024-07-13 - 빈 디렉토리 상태의 접근성(Accessibility) 개선 **Learning:** 정적 파일 서버의 빈 디렉토리 상태는 스크린 리더 사용자에게 컨텐츠 누락으로 오해받을 수 있으며, 시각적으로도 일반 리스트 아이템과 정렬이 맞지 않는 문제가 있었습니다. **Action:** 빈 상태를 나타내는 요소에 `role="status"`를 추가하여 스크린 리더가 명확하게 인지할 수 있도록 하고, 아이콘과 flex 레이아웃을 통해 다른 리스트 아이템과 일관된 시각적 흐름을 제공하도록 합니다. +## 2026-08-10 - 빈 디렉토리 이름 Fallback 텍스트 제공 +**학습:** 루트 디렉토리와 같이 File.getName()이 빈 문자열을 반환하는 경우 생성된 HTML의 과 <h1>이 비어 있게 되어 화면 판독기 사용자에게 혼란을 줍니다. +**조치:** 디렉토리 이름이 빈 문자열인 경우 "Root"(또는 유사한 Fallback 텍스트)를 제공하여 접근성을 향상시키고 정보 누락을 방지하십시오. 절대 경로를 사용하면 서버 구조가 노출되므로 주의하십시오. diff --git a/src/main/kotlin/html4tree/main.kt b/src/main/kotlin/html4tree/main.kt index 8942c047..155743d6 100644 --- a/src/main/kotlin/html4tree/main.kt +++ b/src/main/kotlin/html4tree/main.kt @@ -352,12 +352,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()} + ${curr_dir.getName().let { if (it.isEmpty()) "Root" else it }.escapeHtml()}
-

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

+

${curr_dir.getName().let { if (it.isEmpty()) "Root" else it }.escapeHtml()}