X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Ffeeds.ts;h=f8ebaf6ed87d65cb360fe6465c56b625d3acd0ca;hb=5037e0e474044d7fc04092158784395a001e5c25;hp=aa16cc99378b2148eeaf4846f9d62e1c3d6df172;hpb=76148b27f7501bac061992136852be4303370c8d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts index aa16cc993..f8ebaf6ed 100644 --- a/server/middlewares/validators/feeds.ts +++ b/server/middlewares/validators/feeds.ts @@ -1,18 +1,18 @@ -import * as express from 'express' +import express from 'express' import { param, query } from 'express-validator' +import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' -import { exists, isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc' +import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID } from '../../helpers/custom-validators/misc' import { logger } from '../../helpers/logger' import { + areValidationErrors, doesAccountIdExist, doesAccountNameWithHostExist, doesUserFeedTokenCorrespond, doesVideoChannelIdExist, - doesVideoChannelNameWithHostExist -} from '../../helpers/middlewares' -import { doesVideoExist } from '../../helpers/middlewares/videos' -import { areValidationErrors } from './utils' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' + doesVideoChannelNameWithHostExist, + doesVideoExist +} from './shared' const feedsFormatValidator = [ param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), @@ -98,7 +98,10 @@ const videoSubscriptionFeedsValidator = [ ] const videoCommentsFeedsValidator = [ - query('videoId').optional().custom(isIdOrUUIDValid), + query('videoId') + .customSanitizer(toCompleteUUID) + .optional() + .custom(isIdOrUUIDValid), async (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking feeds parameters', { parameters: req.query })