프로젝트

일반

사용자정보

이슈 #238

Ryan Lee이(가) 7달 전에 변경

마크다운 코드 블록에서 HTML 파싱 

 ## 완료 내역 
 - `parseCodeBlocks(input)` 함수 구현 (`src/utils/parseCodeBlocks.ts`) 
   - 마크다운 코드 펜스(```lang\ncode```)를 정규식으로 매칭하여 `CodeAttachment` 로 변환 
   - AXI가 fence 없이 원시 HTML(`<!DOCTYPE html>...</html>`)을 뱉는 경우 대비 폴백 파서 
   - `max_tokens` 트렁케이션으로 `</html>` 닫기 태그가 없는 부분 응답도 `<!DOCTYPE html>` 시작점부터 끝까지 HTML로 추출 (끊긴 HTML이 텍스트로 누출되지 않도록 방어) 
 - 첨부 메타 생성: 
   - `id` 는 `att-{timestamp}-{rand}` 형식 
   - `title` 은 HTML `<title>` 태그에서 추출 (파일명 안전 문자 sanitize, 40자 제한) / 없으면 `preview-N.ext` 
   - `language` → 확장자 매핑 (html/js/ts/css/json/md/txt) 
   - `lineCount`, `byteCount` 계산 
 - 첨부 렌더링 및 영속화 연동: 
   - `AttachmentCard` 로 대화 내 첨부 카드 UI (`src/components/AttachmentCard.tsx`) 
   - `HtmlViewerScreen` + WebView 로 HTML 전체 렌더 (`src/screens/Chat/HtmlViewerScreen.tsx`) 
   - `WebViewLoader` 로딩 인디케이터 (`src/components/WebViewLoader.tsx`) 
   - `htmlFiles` 서비스로 파일 영속화 (`src/services/storage/htmlFiles.ts`) 
 - 텍스트 본문과 첨부를 분리해 반환 (`ParsedMessage { text, attachments }`) 
 - 설정 화면에서 HTML 저장 디렉토리 초기화 기능 연동 (`src/screens/Settings/SettingsScreen.tsx`) 

 ## 주요 파일 
 - `src/utils/parseCodeBlocks.ts` — 핵심 파서 
 - `src/components/AttachmentCard.tsx` — 첨부 카드 UI 
 - `src/screens/Chat/HtmlViewerScreen.tsx` — HTML WebView 렌더 
 - `src/components/WebViewLoader.tsx` — WebView 로딩 오버레이 
 - `src/services/storage/htmlFiles.ts` — HTML 영속화 
 - `src/screens/Settings/SettingsScreen.tsx` — HTML 저장소 초기화 UI 

 ## 관련 커밋 
 - `91a0930` (fixes ref #238) — AI 응답에서 HTML 추출 로직 

 ## 후속 처리 
 - #243 (6-4): HTML 검증 및 보안 처리 (XSS 방지, CDN allowlist, CSP 주입) — 서버 작업 확정 후 재개 예정 (현재 보류) 

뒤로