Skip to content

Commit

Permalink
Update HLS chunk regex (#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed Oct 30, 2023
1 parent 797d09c commit f4d2228
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/services/rtsp-camera/utils/validateStreamParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const validateSessionId = (sessionId) => {
};

const AUTHORIZED_FILENAMES = ['index.m3u8', 'index.m3u8.key', 'key_info_file.txt'];
const HLS_CHUNK_REGEX = /index[0-9]+.ts/;
const HLS_CHUNK_REGEX = /^index[0-9]+.ts$/;

const validateFilename = (filename) => {
if (AUTHORIZED_FILENAMES.includes(filename)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ describe('camera controller test', () => {
);
await chaiAssert.isRejected(promise, 'Invalid filename');
});
it('should return 400, bad request, invalid filename', async () => {
const rtspCameraController = RtspCameraController(gladys, rtspCameraService);
const req = {
params: {
folder: 'camera-1',
file: '`index1.tslala',
},
};
const resWriteStream = {};
const promise = rtspCameraController['get /api/v1/service/rtsp-camera/camera/streaming/:folder/:file'].controller(
req,
resWriteStream,
);
await chaiAssert.isRejected(promise, 'Invalid filename');
});
it('should return 400, bad request, invalid session id', async () => {
const rtspCameraController = RtspCameraController(gladys, rtspCameraService);
const req = {
Expand Down

0 comments on commit f4d2228

Please sign in to comment.