From 3b7c4d004fa21968ed9ea02b4a7b90e5f18fcc01 Mon Sep 17 00:00:00 2001 From: Michael Linares <116801315+Michaellinaresxk@users.noreply.github.com> Date: Thu, 14 Sep 2023 12:40:26 +0200 Subject: [PATCH] BC-482-character-not-shown-properly (#3291) * Added functionality to display & character instead of & on theme creation. * Added decode to teams edit and topics. --- controllers/teams.js | 13 +++++++++++++ controllers/topics.js | 3 +++ 2 files changed, 16 insertions(+) diff --git a/controllers/teams.js b/controllers/teams.js index addf302e37..0c813204f9 100644 --- a/controllers/teams.js +++ b/controllers/teams.js @@ -4,6 +4,7 @@ const _ = require('lodash'); const express = require('express'); const moment = require('moment'); const { Configuration } = require('@hpi-schul-cloud/commons'); +const { decode } = require('html-entities'); const authHelper = require('../helpers/authentication'); const recurringEventsHelper = require('../helpers/recurringEvents'); @@ -155,6 +156,10 @@ const editTeamHandler = async (req, res, next) => { if (req.params.teamId && !permissions.includes('RENAME_TEAM')) { return next(new Error(res.$t('global.text.403'))); } + + if (team.description) team.description = decode(team.description); + if (team.name) team.name = decode(team.name); + return res.render('teams/edit-team', { action, method, @@ -427,6 +432,9 @@ router.get('/:teamId/json', (req, res, next) => { return permission; }); + if (team.description) team.description = decode(team.description); + if (team.name) team.name = decode(team.name); + res.json({ team }); }) .catch((err) => { @@ -473,6 +481,11 @@ router.get('/:teamId', async (req, res, next) => { }, }); + if (course.description && course.name) { + course.description = decode(course.description); + course.name = decode(course.name); + } + let instanceUsesRocketChat = Configuration.get('ROCKETCHAT_SERVICE_ENABLED'); if (Configuration.has('ROCKET_CHAT_DEPRECATION_DATE')) { const deprecationDate = new Date(Configuration.get('ROCKET_CHAT_DEPRECATION_DATE')); diff --git a/controllers/topics.js b/controllers/topics.js index 012b50c6d9..a2087b8896 100644 --- a/controllers/topics.js +++ b/controllers/topics.js @@ -47,6 +47,9 @@ const editTopicHandler = (req, res, next) => { const { filesStorage } = await filesStoragesHelper .filesStorageInit(schoolId, lesson._id, 'lessons', false, req); + if (lesson.title) lesson.title = decode(lesson.title); + if (lesson.contents) lesson.contents = decode(lesson.contents); + res.render('topic/edit-topic', { action, method,