diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-03-22 21:47:05 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-03-22 21:56:02 +0100 |
commit | e54163c2d5cc925eb56ead831f2fecd000222a98 (patch) | |
tree | 142d0592d66d90b489f592a867770235315bee0c /server | |
parent | 6e07c3de88791a0b342e0cc319590048117f9c2d (diff) | |
download | PeerTube-e54163c2d5cc925eb56ead831f2fecd000222a98.tar.gz PeerTube-e54163c2d5cc925eb56ead831f2fecd000222a98.tar.zst PeerTube-e54163c2d5cc925eb56ead831f2fecd000222a98.zip |
Relax on tags (accept any characters and not required anymore)
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/custom-validators/videos.js | 3 | ||||
-rw-r--r-- | server/initializers/constants.js | 2 | ||||
-rw-r--r-- | server/middlewares/validators/videos.js | 2 | ||||
-rw-r--r-- | server/tests/api/check-params/videos.js | 13 |
4 files changed, 3 insertions, 17 deletions
diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js index 92b366717..efa89c427 100644 --- a/server/helpers/custom-validators/videos.js +++ b/server/helpers/custom-validators/videos.js | |||
@@ -69,8 +69,7 @@ function isVideoTagsValid (tags) { | |||
69 | return miscValidators.isArray(tags) && | 69 | return miscValidators.isArray(tags) && |
70 | validator.isInt(tags.length, VIDEOS_CONSTRAINTS_FIELDS.TAGS) && | 70 | validator.isInt(tags.length, VIDEOS_CONSTRAINTS_FIELDS.TAGS) && |
71 | tags.every(function (tag) { | 71 | tags.every(function (tag) { |
72 | return validator.isAlphanumeric(tag) && | 72 | return validator.isLength(tag, VIDEOS_CONSTRAINTS_FIELDS.TAG) |
73 | validator.isLength(tag, VIDEOS_CONSTRAINTS_FIELDS.TAG) | ||
74 | }) | 73 | }) |
75 | } | 74 | } |
76 | 75 | ||
diff --git a/server/initializers/constants.js b/server/initializers/constants.js index 6c5287b19..40f01e389 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js | |||
@@ -85,7 +85,7 @@ const CONSTRAINTS_FIELDS = { | |||
85 | EXTNAME: [ '.mp4', '.ogv', '.webm' ], | 85 | EXTNAME: [ '.mp4', '.ogv', '.webm' ], |
86 | INFO_HASH: { min: 40, max: 40 }, // Length, infohash is 20 bytes length but we represent it in hexa so 20 * 2 | 86 | INFO_HASH: { min: 40, max: 40 }, // Length, infohash is 20 bytes length but we represent it in hexa so 20 * 2 |
87 | DURATION: { min: 1, max: 7200 }, // Number | 87 | DURATION: { min: 1, max: 7200 }, // Number |
88 | TAGS: { min: 1, max: 3 }, // Number of total tags | 88 | TAGS: { min: 0, max: 3 }, // Number of total tags |
89 | TAG: { min: 2, max: 10 }, // Length | 89 | TAG: { min: 2, max: 10 }, // Length |
90 | THUMBNAIL: { min: 2, max: 30 }, | 90 | THUMBNAIL: { min: 2, max: 30 }, |
91 | THUMBNAIL_DATA: { min: 0, max: 20000 }, // Bytes | 91 | THUMBNAIL_DATA: { min: 0, max: 20000 }, // Bytes |
diff --git a/server/middlewares/validators/videos.js b/server/middlewares/validators/videos.js index 37cc13372..cf3874a97 100644 --- a/server/middlewares/validators/videos.js +++ b/server/middlewares/validators/videos.js | |||
@@ -23,7 +23,7 @@ function videosAdd (req, res, next) { | |||
23 | req.checkBody('name', 'Should have a valid name').isVideoNameValid() | 23 | req.checkBody('name', 'Should have a valid name').isVideoNameValid() |
24 | req.checkBody('category', 'Should have a valid category').isVideoCategoryValid() | 24 | req.checkBody('category', 'Should have a valid category').isVideoCategoryValid() |
25 | req.checkBody('description', 'Should have a valid description').isVideoDescriptionValid() | 25 | req.checkBody('description', 'Should have a valid description').isVideoDescriptionValid() |
26 | req.checkBody('tags', 'Should have correct tags').isVideoTagsValid() | 26 | req.checkBody('tags', 'Should have correct tags').optional().isVideoTagsValid() |
27 | 27 | ||
28 | logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files }) | 28 | logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files }) |
29 | 29 | ||
diff --git a/server/tests/api/check-params/videos.js b/server/tests/api/check-params/videos.js index fbfe6f137..25b4eae31 100644 --- a/server/tests/api/check-params/videos.js +++ b/server/tests/api/check-params/videos.js | |||
@@ -251,19 +251,6 @@ describe('Test videos API validator', function () { | |||
251 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | 251 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) |
252 | }) | 252 | }) |
253 | 253 | ||
254 | it('Should fail with malformed tags', function (done) { | ||
255 | const data = { | ||
256 | name: 'my super name', | ||
257 | category: 5, | ||
258 | description: 'my super description', | ||
259 | tags: [ 'my tag' ] | ||
260 | } | ||
261 | const attach = { | ||
262 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
263 | } | ||
264 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | ||
265 | }) | ||
266 | |||
267 | it('Should fail without an input file', function (done) { | 254 | it('Should fail without an input file', function (done) { |
268 | const data = { | 255 | const data = { |
269 | name: 'my super name', | 256 | name: 'my super name', |