diff --git a/app/src/Server.js b/app/src/Server.js index e4a6b6ce..c75fc81e 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -661,7 +661,7 @@ function startServer() { // Rec_test_2024_08_03_16_17_01.webm - if (!isValidRecFileNameFormat(fileName)) { + if (!fileName.startsWith('Rec_') && !fileName.endsWith('.webm')) { log.warn('[RecSync] - Invalid file name', fileName); return res.status(400).send('Invalid file name'); } @@ -2960,12 +2960,4 @@ function startServer() { } } } - - // Utils... - - function isValidRecFileNameFormat(input) { - const pattern = - /^Rec_(?:[A-Za-z0-9-_]+|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})_\d{4}_\d{2}_\d{2}_\d{2}_\d{2}_\d{2}\.(webm)$/; - return pattern.test(input); - } } diff --git a/cloud/server.js b/cloud/server.js index 99625e9d..0a626556 100644 --- a/cloud/server.js +++ b/cloud/server.js @@ -50,7 +50,7 @@ app.post('/recSync', (req, res) => { return res.status(400).send('Filename not provided'); } - if (!isValidRecFileNameFormat(fileName)) { + if (!fileName.startsWith('Rec_') && !fileName.endsWith('.webm')) { log.warn('[RecSync] - Invalid file name', fileName); return res.status(400).send('Invalid file name'); } @@ -86,9 +86,3 @@ app.post('/recSync', (req, res) => { app.listen(port, () => { log.debug(`Server is running on http://localhost:${port}`); }); - -function isValidRecFileNameFormat(input) { - const pattern = - /^Rec_(?:[A-Za-z0-9-_]+|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})_\d{4}_\d{2}_\d{2}_\d{2}_\d{2}_\d{2}\.(webm)$/; - return pattern.test(input); -}