throw error 400 when start or endtime has colon

This commit is contained in:
Michael C
2021-08-24 19:12:58 -04:00
parent 954ac1eb07
commit c3f7b29d44
2 changed files with 31 additions and 0 deletions

View File

@@ -324,6 +324,15 @@ function checkInvalidFields(videoID: any, userID: any, segments: Array<any>): Ch
if (!Array.isArray(segments) || segments.length < 1) {
invalidFields.push("segments");
}
// validate start and end times (no : marks)
for (const segmentPair of segments) {
const startTime = segmentPair.segment[0];
const endTime = segmentPair.segment[1];
if ((typeof startTime === "string" && startTime.includes(":")) ||
(typeof endTime === "string" && endTime.includes(":"))) {
invalidFields.push("segment time");
}
}
if (invalidFields.length !== 0) {
// invalid request