Merge pull request #342 from mchangrh/no-colon

throw error 400 when start or endtime has colon
This commit is contained in:
Ajay Ramachandran
2021-08-28 00:14:52 -04:00
committed by GitHub
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