Merge remote-tracking branch 'origin/master' into hashtalk

v1.18.x
barisusakli 10 years ago
commit 655f5087d9

@ -1,6 +1,7 @@
'use strict'; 'use strict';
var user = require('../user'), var winston = require('winston'),
user = require('../user'),
translator = require('../../public/src/translator'); translator = require('../../public/src/translator');
module.exports = function(Meta) { module.exports = function(Meta) {
@ -14,7 +15,14 @@ module.exports = function(Meta) {
}; };
Meta.title.build = function (urlFragment, language, callback) { Meta.title.build = function (urlFragment, language, callback) {
Meta.title.parseFragment(decodeURIComponent(urlFragment), language, function(err, title) { var uri = '';
try {
uri = decodeURIComponent(urlFragment);
} catch(e) {
winston.error('Invalid url fragment : ' + urlFragment, e.stack);
return callback(null, Meta.config.browserTitle || 'NodeBB');
}
Meta.title.parseFragment(uri, language, function(err, title) {
if (err) { if (err) {
title = Meta.config.browserTitle || 'NodeBB'; title = Meta.config.browserTitle || 'NodeBB';
} else { } else {

@ -298,7 +298,7 @@ var async = require('async'),
} }
posts = posts.filter(function(post) { posts = posts.filter(function(post) {
return parseInt(results.topics[post.tid].deleted, 10) !== 1; return results.topics[post.tid] && parseInt(results.topics[post.tid].deleted, 10) !== 1;
}); });
async.map(posts, function(post, next) { async.map(posts, function(post, next) {

@ -174,9 +174,9 @@ var async = require('async'),
Topics.getTopicsData(tids, function(err, topics) { Topics.getTopicsData(tids, function(err, topics) {
function mapFilter(array, field) { function mapFilter(array, field) {
return array.map(function(topic) { return array.map(function(topic) {
return topic[field]; return topic && topic[field];
}).filter(function(value, index, array) { }).filter(function(value, index, array) {
return array.indexOf(value) === index; return value && array.indexOf(value) === index;
}); });
} }
@ -219,21 +219,23 @@ var async = require('async'),
}); });
for (var i=0; i<topics.length; ++i) { for (var i=0; i<topics.length; ++i) {
topics[i].category = categories[topics[i].cid]; if (topics[i]) {
topics[i].category.disabled = parseInt(topics[i].category.disabled, 10) === 1; topics[i].category = categories[topics[i].cid];
topics[i].user = users[topics[i].uid]; topics[i].category.disabled = parseInt(topics[i].category.disabled, 10) === 1;
topics[i].teaser = results.teasers[i]; topics[i].user = users[topics[i].uid];
topics[i].tags = results.tags[i]; topics[i].teaser = results.teasers[i];
topics[i].tags = results.tags[i];
topics[i].pinned = parseInt(topics[i].pinned, 10) === 1;
topics[i].locked = parseInt(topics[i].locked, 10) === 1; topics[i].pinned = parseInt(topics[i].pinned, 10) === 1;
topics[i].deleted = parseInt(topics[i].deleted, 10) === 1; topics[i].locked = parseInt(topics[i].locked, 10) === 1;
topics[i].unread = !(results.hasRead[i] && parseInt(uid, 10) !== 0); topics[i].deleted = parseInt(topics[i].deleted, 10) === 1;
topics[i].unreplied = parseInt(topics[i].postcount, 10) <= 1; topics[i].unread = !(results.hasRead[i] && parseInt(uid, 10) !== 0);
topics[i].unreplied = parseInt(topics[i].postcount, 10) <= 1;
}
} }
topics = topics.filter(function(topic) { topics = topics.filter(function(topic) {
return !topic.category.disabled && return topic && !topic.category.disabled &&
(!topic.deleted || (topic.deleted && isAdminOrMod[topic.cid]) || (!topic.deleted || (topic.deleted && isAdminOrMod[topic.cid]) ||
parseInt(topic.uid, 10) === parseInt(uid, 10)); parseInt(topic.uid, 10) === parseInt(uid, 10));
}); });

Loading…
Cancel
Save