Skip to content

Node.js based forum software built for the modern web

fix: do not blindly escape a notification's bodyLong

Julian Lam783786cf8cbc
diff --git a/src/flags.js b/src/flags.js
index 3fd707058d..28f5733794 100644
--- a/src/flags.js
+++ b/src/flags.js
@@ -720,7 +720,7 @@ Flags.notify = async function (flagObj, uid) {
notifObj = await notifications.create({
type: 'new-post-flag',
bodyShort: `[[notifications:user_flagged_post_in, ${flagObj.reports[flagObj.reports.length - 1].reporter.username}, ${titleEscaped}]]`,
- bodyLong: flagObj.description,
+ bodyLong: await plugins.hooks.fire('filter:parse.raw', flagObj.description),
pid: flagObj.targetId,
path: `/flags/${flagObj.flagId}`,
nid: `flag:post:${flagObj.targetId}`,
@@ -733,7 +733,7 @@ Flags.notify = async function (flagObj, uid) {
notifObj = await notifications.create({
type: 'new-user-flag',
bodyShort: `[[notifications:user_flagged_user, ${flagObj.reports[flagObj.reports.length - 1].reporter.username}, ${flagObj.target.username}]]`,
- bodyLong: flagObj.description,
+ bodyLong: await plugins.hooks.fire('filter:parse.raw', flagObj.description),
path: `/flags/${flagObj.flagId}`,
nid: `flag:user:${flagObj.targetId}`,
from: uid,
diff --git a/src/messaging/notifications.js b/src/messaging/notifications.js
index 748fd2799c..d76348a29a 100644
--- a/src/messaging/notifications.js
+++ b/src/messaging/notifications.js
@@ -62,7 +62,7 @@ module.exports = function (Messaging) {
type: isGroupChat ? 'new-group-chat' : 'new-chat',
subject: `[[email:notif.chat.subject, ${messageObj.fromUser.username}]]`,
bodyShort: `[[notifications:new_message_from, ${messageObj.fromUser.username}]]`,
- bodyLong: messageObj.content,
+ bodyLong: await plugins.hooks.fire('filter:parse.raw', messageObj.content),
nid: `chat_${fromuid}_${roomId}`,
from: fromuid,
path: `/chats/${messageObj.roomId}`,
diff --git a/src/notifications.js b/src/notifications.js
index 332301cebc..66162c935a 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -75,7 +75,7 @@ Notifications.getMultiple = async function (nids) {
notification.datetimeISO = utils.toISOString(notification.datetime);
if (notification.bodyLong) {
- notification.bodyLong = utils.escapeHTML(notification.bodyLong);
+ notification.bodyLong = utils.stripHTMLTags(notification.bodyLong, ['img', 'p', 'a']);
}
notification.user = usersData[index];
diff --git a/src/posts/queue.js b/src/posts/queue.js
index bd24811ebc..19fc0b1131 100644
--- a/src/posts/queue.js
+++ b/src/posts/queue.js
@@ -95,7 +95,7 @@ module.exports = function (Posts) {
nid: `post-queue-${id}`,
mergeId: 'post-queue',
bodyShort: '[[notifications:post_awaiting_review]]',
- bodyLong: data.content,
+ bodyLong: await plugins.hooks.fire('filter:parse.raw', data.content),
path: '/post-queue',
});
await notifications.push(notifObj, uids);