From 2d4fc5d4c4fb5136b1a90f374e1090658129c8a5 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Thu, 4 Sep 2025 06:25:57 +0000
Subject: (김준회) 옥창명 프로 요구사항 반영 - 도면업로드시 특수문자불가 가이드
 문구 추가, 실패시 간략한 원인 안내, 기준정보 프로젝트 메뉴에서 getProject
 버튼 숨김
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../ship-vendor-document/add-attachment-dialog.tsx | 47 +++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

(limited to 'components/ship-vendor-document/add-attachment-dialog.tsx')

diff --git a/components/ship-vendor-document/add-attachment-dialog.tsx b/components/ship-vendor-document/add-attachment-dialog.tsx
index 1e9bfb51..8c5e17c8 100644
--- a/components/ship-vendor-document/add-attachment-dialog.tsx
+++ b/components/ship-vendor-document/add-attachment-dialog.tsx
@@ -147,6 +147,9 @@ function FileUploadArea({
         <p className="text-xs text-gray-500">
           Supports PDF, Word, Excel, Image, Text, ZIP, CAD files (DWG, DXF, STEP, STL, IGES) (max 1GB)
         </p>
+        <p className="text-xs text-orange-600 mt-1">
+          Note: File names cannot contain these characters: &lt; &gt; : &quot; &apos; | ? *
+        </p>
         <input
           ref={fileInputRef}
           type="file"
@@ -285,7 +288,49 @@ export function AddAttachmentDialog({
   
       } catch (error) {
         console.error('❌ Attachment upload error:', error)
-        toast.error(error instanceof Error ? error.message : "An error occurred while uploading attachments")
+        
+        let userMessage = "An error occurred while uploading attachments"
+        
+        if (error instanceof Error) {
+          const message = error.message.toLowerCase()
+          
+          // 파일명 관련 에러 (보안상 허용)
+          if (message.includes("안전하지 않은 파일명") || message.includes("unsafe filename") || 
+              message.includes("filename") && message.includes("invalid")) {
+            userMessage = "File name contains invalid characters. Please avoid using < > : \" ' | ? * in file names. filename can't start with '..'."
+          }
+          // 파일명 길이 에러 (보안상 허용)
+          else if (message.includes("파일명이 너무 깁니다") || message.includes("filename too long") ||
+                   message.includes("파일명") && message.includes("길이")) {
+            userMessage = "File name is too long. Please use a shorter name (max 255 characters)."
+          }
+          // 파일 크기 에러 (보안상 허용)
+          else if (message.includes("파일 크기가 너무 큽니다") || message.includes("file size") || 
+                   message.includes("1gb limit") || message.includes("exceeds") && message.includes("limit")) {
+            userMessage = "File size is too large. Please use files smaller than 1GB."
+          }
+          // 클라이언트측 네트워크 에러 (기존과 같이 처리)
+          else if (message.includes("network") || message.includes("fetch") || 
+                   message.includes("connection") || message.includes("timeout")) {
+            userMessage = "Network error occurred. Please check your connection and try again."
+          }
+          // 서버측 오류는 보안상 일반적인 메시지로 처리
+          else if (message.includes("500") || message.includes("server") || 
+                   message.includes("database") || message.includes("internal") ||
+                   message.includes("security") || message.includes("validation")) {
+            userMessage = "Please try again later. If the problem persists, please contact the administrator."
+          }
+          // 기타 알려진 클라이언트 에러는 원본 메시지 사용 (영어인 경우)
+          else if (!/[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/.test(error.message) && error.message.length < 200) {
+            userMessage = error.message
+          }
+          // 그 외는 일반적인 메시지
+          else {
+            userMessage = "Please try again later. If the problem persists, please contact the administrator."
+          }
+        }
+        
+        toast.error(userMessage)
       } finally {
         setIsUploading(false)
         setTimeout(() => setUploadProgress(0), 2000)
-- 
cgit v1.2.3

