mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
fix notifications that contain topic titles with commas in them
This commit is contained in:
@@ -450,10 +450,13 @@ var async = require('async'),
|
|||||||
});
|
});
|
||||||
var numUsers = usernames.length;
|
var numUsers = usernames.length;
|
||||||
|
|
||||||
|
var title = S(notifications[modifyIndex].topicTitle).decodeHTMLEntities().s;
|
||||||
|
var titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
||||||
|
|
||||||
if (numUsers === 2) {
|
if (numUsers === 2) {
|
||||||
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_dual, ' + usernames.join(', ') + ', ' + notifications[modifyIndex].topicTitle + ']]';
|
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_dual, ' + usernames.join(', ') + ', ' + titleEscaped + ']]';
|
||||||
} else if (numUsers > 2) {
|
} else if (numUsers > 2) {
|
||||||
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers-1) + ', ' + notifications[modifyIndex].topicTitle + ']]';
|
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers-1) + ', ' + titleEscaped + ']]';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var winston = require('winston');
|
var winston = require('winston');
|
||||||
|
var S = require('string');
|
||||||
var nconf = require('nconf');
|
var nconf = require('nconf');
|
||||||
|
|
||||||
var websockets = require('./index');
|
var websockets = require('./index');
|
||||||
@@ -62,8 +63,11 @@ SocketHelpers.sendNotificationToPostOwner = function(pid, fromuid, notification)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var title = S(results.topicTitle).decodeHTMLEntities().s;
|
||||||
|
var titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
||||||
|
|
||||||
notifications.create({
|
notifications.create({
|
||||||
bodyShort: '[[' + notification + ', ' + results.username + ', ' + results.topicTitle + ']]',
|
bodyShort: '[[' + notification + ', ' + results.username + ', ' + titleEscaped + ']]',
|
||||||
bodyLong: results.postObj.content,
|
bodyLong: results.postObj.content,
|
||||||
pid: pid,
|
pid: pid,
|
||||||
nid: 'post:' + pid + ':uid:' + fromuid,
|
nid: 'post:' + pid + ':uid:' + fromuid,
|
||||||
@@ -93,8 +97,11 @@ SocketHelpers.sendNotificationToTopicOwner = function(tid, fromuid, notification
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var title = S(results.topicData.title).decodeHTMLEntities().s;
|
||||||
|
var titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
||||||
|
|
||||||
notifications.create({
|
notifications.create({
|
||||||
bodyShort: '[[' + notification + ', ' + results.username + ', ' + results.topicData.title + ']]',
|
bodyShort: '[[' + notification + ', ' + results.username + ', ' + titleEscaped + ']]',
|
||||||
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug,
|
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug,
|
||||||
nid: 'tid:' + tid + ':uid:' + fromuid,
|
nid: 'tid:' + tid + ':uid:' + fromuid,
|
||||||
from: fromuid
|
from: fromuid
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
|
var S = require('string');
|
||||||
|
|
||||||
var user = require('../../user');
|
var user = require('../../user');
|
||||||
var groups = require('../../groups');
|
var groups = require('../../groups');
|
||||||
@@ -82,8 +83,11 @@ module.exports = function(SocketPosts) {
|
|||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
|
var title = S(post.topic.title).decodeHTMLEntities().s;
|
||||||
|
var titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
||||||
|
|
||||||
notifications.create({
|
notifications.create({
|
||||||
bodyShort: '[[notifications:user_flagged_post_in, ' + flaggingUser.username + ', ' + post.topic.title + ']]',
|
bodyShort: '[[notifications:user_flagged_post_in, ' + flaggingUser.username + ', ' + titleEscaped + ']]',
|
||||||
bodyLong: post.content,
|
bodyLong: post.content,
|
||||||
pid: data.pid,
|
pid: data.pid,
|
||||||
nid: 'post_flag:' + data.pid + ':uid:' + socket.uid,
|
nid: 'post_flag:' + data.pid + ':uid:' + socket.uid,
|
||||||
|
|||||||
Reference in New Issue
Block a user