Skip to content

Update HLS chunk regex #1918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update HLS chunk regex
  • Loading branch information
Pierre-Gilles committed Oct 30, 2023
commit 4f56ba250ff9f46578f1afa6a97e62e74bad83b7
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