From bac94738fd150ef956883f438a265bc94c905a39 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Tue, 4 Aug 2020 19:09:31 +0200 Subject: [PATCH] feat: sanitize short description --- src/controllers/DelegateController.ts | 5 +++++ src/controllers/PublicController.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/controllers/DelegateController.ts b/src/controllers/DelegateController.ts index c93a22a..6a156d1 100644 --- a/src/controllers/DelegateController.ts +++ b/src/controllers/DelegateController.ts @@ -55,6 +55,11 @@ export default class DelegateController { proposedVersion.contacts.peoples = proposedVersion.contacts.peoples.filter((p: any) => !p.isResponsable) } + // sanitize short description + if (Utils.isStrUsable(proposedVersion.shortDescription)) { + proposedVersion.shortDescription = proposedVersion.shortDescription.replace(/\n/g, '') + } + // sanitize long description if (Utils.isStrUsable(proposedVersion.descriptionLong)) { proposedVersion.descriptionLong = proposedVersion.descriptionLong.replace(/\n/g, '') diff --git a/src/controllers/PublicController.ts b/src/controllers/PublicController.ts index b3f02c8..395c6c7 100644 --- a/src/controllers/PublicController.ts +++ b/src/controllers/PublicController.ts @@ -51,7 +51,7 @@ export default class PublicController { return { _id: o._id, name: version.name, - description: version.descriptionShort, + description: version.descriptionShort.replace(/\n/g, ''), thumbnail: version.thumbnail.key, tags: version.tags === null ? 'tags_not_found' : version.tags, slug: o.get('slugs')[o.get('slugs').length -1]