From a996fc4abef3a02a7299a92dbcbdd6425b160af7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 16 May 2016 19:51:07 +0200 Subject: [PATCH] Add check for the author username length --- server/helpers/customValidators.js | 1 + server/initializers/constants.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/server/helpers/customValidators.js b/server/helpers/customValidators.js index 9b982369e..b95e2b9bb 100644 --- a/server/helpers/customValidators.js +++ b/server/helpers/customValidators.js @@ -19,6 +19,7 @@ function eachIsRemoteVideosAddValid (values) { !isNaN(val.duration) && val.duration >= 0 && val.duration < constants.MAXIMUM_VIDEO_DURATION && + validator.isLength(val.author, 1, constants.MAXIMUM_AUTHOR_LENGTH) && validator.isDate(val.createdDate) }) } diff --git a/server/initializers/constants.js b/server/initializers/constants.js index d87a376d3..78bee5efe 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js @@ -9,6 +9,8 @@ let FRIEND_BASE_SCORE = 100 // Time to wait between requests to the friends let INTERVAL = 60000 +// Max length of the author username +const MAXIMUM_AUTHOR_LENGTH = 20 // 2 hours maximum for the duration of a video (in seconds) let MAXIMUM_VIDEO_DURATION = 7200 @@ -44,6 +46,7 @@ module.exports = { API_VERSION: API_VERSION, FRIEND_BASE_SCORE: FRIEND_BASE_SCORE, INTERVAL: INTERVAL, + MAXIMUM_AUTHOR_LENGTH: MAXIMUM_AUTHOR_LENGTH, MAXIMUM_VIDEO_DURATION: MAXIMUM_VIDEO_DURATION, PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT, PODS_SCORE: PODS_SCORE,