fix(videos): reject bad-format id in idAvailable (P2 review fix)

`videoIdExists()`는 잘못된 형식의 ID 에 대해 false 를 반환하기 때문에
형식 오류가 곧바로 `{available:true}` 로 흘러나가는 계약 위반이 있었다.
이제 빈 값 검사 직후 `isSafeVideoId` 로 형식을 먼저 거르고,
형식 오류면 `{available:false, reason:'형식: 영문/숫자/_/- (1~64자)'}`
로 응답한다. 클라이언트 regex 와 동일한 형식이라 메시지도 일관된다.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Claude (owner)
2026-05-31 23:55:55 +09:00
parent 55ce30733b
commit 652df2dbdb

View File

@@ -14,6 +14,7 @@ import {
getFolder,
getFolderByPath,
getVideo,
isSafeVideoId,
listChildFolders,
listTopFolders,
listVideosInFolder,
@@ -352,6 +353,14 @@ opRouter.get('/op/videos/idAvailable', requireAuth, (req, res) => {
res.json({ ok: true, available: false, reason: '비어 있음' })
return
}
if (!isSafeVideoId(id)) {
res.json({
ok: true,
available: false,
reason: '형식: 영문/숫자/_/- (1~64자)'
})
return
}
const available = !videoIdExists(id)
res.json({ ok: true, available })
})