From fb764472dd305850637de38fea74ac9ebccb012d Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 23 Sep 2014 13:48:15 -0400 Subject: [PATCH 1/5] closes #2125 --- public/src/forum/topic/postTools.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/src/forum/topic/postTools.js b/public/src/forum/topic/postTools.js index 2bc22cb06a..a4b7708e2a 100644 --- a/public/src/forum/topic/postTools.js +++ b/public/src/forum/topic/postTools.js @@ -131,7 +131,9 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com } var username = getUserName(selectionText ? $(selection.baseNode) : button); - + if (getData(button, 'data-uid') === '0') { + username = ''; + } if (selectionText.length) { composer.addQuote(tid, ajaxify.variables.get('topic_slug'), getData(button, 'data-index'), getData(button, 'data-pid'), topicName, username, selectionText); } else { @@ -201,8 +203,12 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com post = button.parents('li[data-pid]'); if (post.length) { - username = '@' + post.attr('data-username').replace(/\s/g, '-'); + username = post.attr('data-username').replace(/\s/g, '-'); } + if (post.attr('data-uid') !== '0') { + username = '@' + username; + } + return username; } From 0eb4fd89ef0d77632f2b349fc58c34bd58a88e31 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 23 Sep 2014 13:57:59 -0400 Subject: [PATCH 2/5] don't blow up nodebb if plugin.json is broken --- src/plugins.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins.js b/src/plugins.js index 41f38dfd3c..ea47125b9c 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -144,8 +144,16 @@ var fs = require('fs'), return callback(pluginPath.match('nodebb-theme') ? null : err); } - var pluginData = JSON.parse(data), - libraryPath, staticDir; + try { + var pluginData = JSON.parse(data), + libraryPath, staticDir; + } catch (err) { + var pluginDir = pluginPath.split(path.sep); + pluginDir = pluginDir[pluginDir.length -1]; + + winston.error('[plugins/' + pluginDir + '] Plugin not loaded - please check its plugin.json for errors'); + return callback(err); + } /* Starting v0.5.0, `minver` is deprecated in favour of `compatibility`. From 77dfc7378b53d9b5b21e2e323350f62d7f6b9702 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 23 Sep 2014 13:58:03 -0400 Subject: [PATCH 3/5] filter:post.getPostSummaryByPids --- src/posts.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/posts.js b/src/posts.js index 1cb277fabb..745e7f0d2f 100644 --- a/src/posts.js +++ b/src/posts.js @@ -343,7 +343,9 @@ var async = require('async'), next(null, post); }); - }, callback); + }, function(err, posts) { + plugins.fireHook('filter:post.getPostSummaryByPids', {posts: posts, uid: uid}, callback); + }); }); }); }; From 180625ece34b05058c5b8662d6c80071446965e7 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 23 Sep 2014 14:00:28 -0400 Subject: [PATCH 4/5] forgot to return just posts array --- src/posts.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/posts.js b/src/posts.js index 745e7f0d2f..dcedf4383d 100644 --- a/src/posts.js +++ b/src/posts.js @@ -344,7 +344,9 @@ var async = require('async'), next(null, post); }); }, function(err, posts) { - plugins.fireHook('filter:post.getPostSummaryByPids', {posts: posts, uid: uid}, callback); + plugins.fireHook('filter:post.getPostSummaryByPids', {posts: posts, uid: uid}, function(err, postData) { + callback(err, postData.posts); + }); }); }); }); From a0da73dabda958b631891c8f3e1a613a52ae5418 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 23 Sep 2014 15:03:13 -0400 Subject: [PATCH 5/5] don't pass back err if plugin.json is corrupted --- src/plugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins.js b/src/plugins.js index ea47125b9c..2cc51316d1 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -152,7 +152,7 @@ var fs = require('fs'), pluginDir = pluginDir[pluginDir.length -1]; winston.error('[plugins/' + pluginDir + '] Plugin not loaded - please check its plugin.json for errors'); - return callback(err); + return callback(); } /*