From 35e2e7480f2248df41fc54532b59e5724e3ed7e4 Mon Sep 17 00:00:00 2001 From: Bagsangbin Date: Sun, 25 May 2025 22:19:18 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Fix:=20=ED=99=95=EC=9E=A5=EC=9E=90=20?= =?UTF-8?q?=EC=A0=9C=ED=95=9C=20=EB=B0=8F=20alter=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(with-navi-footer)/(resource)/secret/edit/page.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/app/(with-navi-footer)/(resource)/secret/edit/page.tsx b/src/app/(with-navi-footer)/(resource)/secret/edit/page.tsx index 3c27db1..be6dcfb 100644 --- a/src/app/(with-navi-footer)/(resource)/secret/edit/page.tsx +++ b/src/app/(with-navi-footer)/(resource)/secret/edit/page.tsx @@ -34,6 +34,13 @@ export default function SecretEditPage() { fileUrl: formData.getAll('filePaths') as string[], }; + if (!(requestBody.imageUrl.length > 0 && (requestBody.imageUrl[0].endsWith('.jpg') + || requestBody.imageUrl[0].endsWith('.png') + || requestBody.imageUrl[0].endsWith('.jpeg')))){ + alert('이미지 파일이 jpg, png, jpeg 형식이어야 합니다.'); + throw new Error('Invalid image format'); + } + const response = await fetch(API_ROUTES.CREATE_ARCHIVE, { method: 'POST', headers: { From 293115bbac0c0c7cf06c5679938fd8ce3adfdd78 Mon Sep 17 00:00:00 2001 From: Bagsangbin Date: Sun, 25 May 2025 22:41:36 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Fix:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EA=B0=80?= =?UTF-8?q?=20=EC=97=AC=EB=9F=AC=EA=B0=9C=20=EC=9D=BC=20=EA=B2=BD=EC=9A=B0?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(resource)/secret/edit/page.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app/(with-navi-footer)/(resource)/secret/edit/page.tsx b/src/app/(with-navi-footer)/(resource)/secret/edit/page.tsx index be6dcfb..4fe73c6 100644 --- a/src/app/(with-navi-footer)/(resource)/secret/edit/page.tsx +++ b/src/app/(with-navi-footer)/(resource)/secret/edit/page.tsx @@ -34,11 +34,22 @@ export default function SecretEditPage() { fileUrl: formData.getAll('filePaths') as string[], }; - if (!(requestBody.imageUrl.length > 0 && (requestBody.imageUrl[0].endsWith('.jpg') - || requestBody.imageUrl[0].endsWith('.png') - || requestBody.imageUrl[0].endsWith('.jpeg')))){ - alert('이미지 파일이 jpg, png, jpeg 형식이어야 합니다.'); + // 이미지의 확장자 유효성 검사, jpg, png, jpeg 형식만 허용 + if (Array.isArray(requestBody.imageUrl) && requestBody.imageUrl.length > 0) { + const isAllValid = requestBody.imageUrl.every((url) => { + const lowerUrl = url.toLowerCase(); + return ( + lowerUrl.endsWith('.jpg') || + lowerUrl.endsWith('.jpeg') || + lowerUrl.endsWith('.png') + ); + }); + + if (!isAllValid) { + console.log(requestBody.imageUrl); + alert('모든 이미지 파일은 jpg, png, jpeg 형식이어야 합니다.'); throw new Error('Invalid image format'); + } } const response = await fetch(API_ROUTES.CREATE_ARCHIVE, {