mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 09:36:08 +00:00
feat(progress): add validation for progress and duration to ensure they are non-negative finite numbers within a reasonable range
This commit is contained in:
@@ -85,11 +85,13 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
|
|||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
const { progress, duration, versionId } = body;
|
const { progress, duration, versionId } = body;
|
||||||
|
|
||||||
if (typeof progress !== 'number' || !isFinite(progress) || progress < 0) {
|
const MAX_VIDEO_SECONDS = 86_400; // 24 hours — reasonable upper bound for any video
|
||||||
|
|
||||||
|
if (typeof progress !== 'number' || !isFinite(progress) || progress < 0 || progress > MAX_VIDEO_SECONDS) {
|
||||||
return apiErrors.badRequest('Invalid progress value');
|
return apiErrors.badRequest('Invalid progress value');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duration !== undefined && (typeof duration !== 'number' || !isFinite(duration) || duration < 0)) {
|
if (duration !== undefined && (typeof duration !== 'number' || !isFinite(duration) || duration < 0 || duration > MAX_VIDEO_SECONDS)) {
|
||||||
return apiErrors.badRequest('Invalid duration value');
|
return apiErrors.badRequest('Invalid duration value');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user