mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-09 21:17:15 +03:00
strict check for videoID length
This commit is contained in:
@@ -302,7 +302,7 @@ async function checkUserActiveWarning(userID: string): Promise<CheckResult> {
|
|||||||
function checkInvalidFields(videoID: VideoID, userID: UserID, segments: IncomingSegment[]): CheckResult {
|
function checkInvalidFields(videoID: VideoID, userID: UserID, segments: IncomingSegment[]): CheckResult {
|
||||||
const invalidFields = [];
|
const invalidFields = [];
|
||||||
const errors = [];
|
const errors = [];
|
||||||
if (typeof videoID !== "string") {
|
if (typeof videoID !== "string" || videoID?.length == 0) {
|
||||||
invalidFields.push("videoID");
|
invalidFields.push("videoID");
|
||||||
}
|
}
|
||||||
if (typeof userID !== "string" || userID?.length < 30) {
|
if (typeof userID !== "string" || userID?.length < 30) {
|
||||||
|
|||||||
@@ -1084,4 +1084,20 @@ describe("postSkipSegments", () => {
|
|||||||
})
|
})
|
||||||
.catch(err => done(err));
|
.catch(err => done(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Should return 400 if videoID is empty", (done) => {
|
||||||
|
const videoID = null as string;
|
||||||
|
postSkipSegmentParam({
|
||||||
|
videoID,
|
||||||
|
startTime: 1,
|
||||||
|
endTime: 5,
|
||||||
|
category: "sponsor",
|
||||||
|
userID: submitUserTwo
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
assert.strictEqual(res.status, 400);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(err => done(err));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user