reverted change where post title was sanitized on saving (which didn't

seem to work), now sanitizing post title on output
v1.18.x
Julian Lam 11 years ago
parent 3d4802ac68
commit 9613ea9018

@ -5,6 +5,7 @@ var RDB = require('./redis.js'),
user = require('./user.js'), user = require('./user.js'),
async = require('async'), async = require('async'),
nconf = require('nconf'), nconf = require('nconf'),
validator = require('validator'),
utils = require('../public/src/utils'), utils = require('../public/src/utils'),
plugins = require('./plugins'), plugins = require('./plugins'),
@ -92,10 +93,9 @@ var RDB = require('./redis.js'),
], function(err, results) { ], function(err, results) {
io.sockets.in('topic_' + results[0].tid).emit('event:post_edited', { io.sockets.in('topic_' + results[0].tid).emit('event:post_edited', {
pid: pid, pid: pid,
title: title, title: validator.sanitize(title).escape(),
isMainPost: results[0].isMainPost, isMainPost: results[0].isMainPost,
content: results[1] content: results[1]
}); });
}); });
}; };

@ -264,9 +264,9 @@ var RDB = require('./redis.js'),
var socketData = { var socketData = {
posts: [postData] posts: [postData]
}; };
io.sockets. in ('topic_' + tid).emit('event:new_post', socketData); io.sockets.in('topic_' + tid).emit('event:new_post', socketData);
io.sockets. in ('recent_posts').emit('event:new_post', socketData); io.sockets.in('recent_posts').emit('event:new_post', socketData);
io.sockets. in ('user/' + uid).emit('event:new_post', socketData); io.sockets.in('user/' + uid).emit('event:new_post', socketData);
}); });
callback(null, 'Reply successful'); callback(null, 'Reply successful');

@ -15,15 +15,17 @@ schema = require('./schema.js'),
topicSearch = reds.createSearch('nodebbtopicsearch'), topicSearch = reds.createSearch('nodebbtopicsearch'),
validator = require('validator'); validator = require('validator');
(function(Topics) { (function(Topics) {
Topics.getTopicData = function(tid, callback) { Topics.getTopicData = function(tid, callback) {
RDB.hgetall('topic:' + tid, function(err, data) { RDB.hgetall('topic:' + tid, function(err, data) {
if (err === null) if (err === null) {
data.title = validator.sanitize(data.title).escape();
callback(data); callback(data);
else } else {
console.log(err); console.log(err);
}
}); });
} }
@ -658,7 +660,6 @@ schema = require('./schema.js'),
var slug = tid + '/' + utils.slugify(title); var slug = tid + '/' + utils.slugify(title);
var timestamp = Date.now(); var timestamp = Date.now();
title = validator.sanitize(title).escape();
RDB.hmset('topic:' + tid, { RDB.hmset('topic:' + tid, {
'tid': tid, 'tid': tid,
'uid': uid, 'uid': uid,
@ -698,9 +699,9 @@ schema = require('./schema.js'),
// Notify any users looking at the category that a new topic has arrived // Notify any users looking at the category that a new topic has arrived
Topics.getTopicForCategoryView(tid, uid, function(topicData) { Topics.getTopicForCategoryView(tid, uid, function(topicData) {
io.sockets. in ('category_' + category_id).emit('event:new_topic', topicData); io.sockets.in('category_' + category_id).emit('event:new_topic', topicData);
io.sockets. in ('recent_posts').emit('event:new_topic', topicData); io.sockets.in('recent_posts').emit('event:new_topic', topicData);
io.sockets. in ('user/' + uid).emit('event:new_post', { io.sockets.in('user/' + uid).emit('event:new_post', {
posts: postData posts: postData
}); });
}); });

@ -309,7 +309,8 @@ var express = require('express'),
}, },
function (topicData, next) { function (topicData, next) {
var lastMod = 0, var lastMod = 0,
timestamp; timestamp,
sanitize = validator.sanitize;
for (var x = 0, numPosts = topicData.posts.length; x < numPosts; x++) { for (var x = 0, numPosts = topicData.posts.length; x < numPosts; x++) {
timestamp = parseInt(topicData.posts[x].timestamp, 10); timestamp = parseInt(topicData.posts[x].timestamp, 10);
@ -324,7 +325,7 @@ var express = require('express'),
content: topicData.topic_name content: topicData.topic_name
}, { }, {
name: "description", name: "description",
content: validator.sanitize(topicData.main_posts[0].content.substr(0, 255)).escape().replace('\n', '') content: sanitize(topicData.main_posts[0].content.substr(0, 255)).escape().replace('\n', '')
}, { }, {
property: 'og:title', property: 'og:title',
content: topicData.topic_name + ' | ' + (meta.config.title || 'NodeBB') content: topicData.topic_name + ' | ' + (meta.config.title || 'NodeBB')

Loading…
Cancel
Save