Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Trim video name also on server

Chocobozzz0221f8c9b174
diff --git a/client/src/app/shared/form-validators/video-validators.ts b/client/src/app/shared/form-validators/video-validators.ts
index 0000f18bab..1382a77478 100644
--- a/client/src/app/shared/form-validators/video-validators.ts
+++ b/client/src/app/shared/form-validators/video-validators.ts
@@ -3,15 +3,14 @@ import { BuildFormValidator } from './form-validator.model'
export const trimValidator: ValidatorFn = (control: FormControl) => {
if (control.value.startsWith(' ') || control.value.endsWith(' ')) {
- return {
- 'spaces': true
- }
+ return { spaces: true }
}
- return null;
-};
+
+ return null
+}
export const VIDEO_NAME_VALIDATOR: BuildFormValidator = {
- VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120), trimValidator ],
+ VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
MESSAGES: {
'required': $localize`Video name is required.`,
'minlength': $localize`Video name must be at least 3 characters long.`,
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 26a671a1e0..be05b2a694 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -62,6 +62,7 @@ const videosAddValidator = getCommonVideoEditAttributes().concat([
.custom((value, { req }) => isFileFieldValid(req.files, 'videofile'))
.withMessage('Should have a file'),
body('name')
+ .trim()
.custom(isVideoNameValid)
.withMessage('Should have a valid name'),
body('channelId')
@@ -129,6 +130,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
body('name')
.optional()
+ .trim()
.custom(isVideoNameValid).withMessage('Should have a valid name'),
body('channelId')
.optional()