Skip to content

Node.js based forum software built for the modern web

fix post export crashing if a pid reference doesn't resolve to an actual post object

Julian Lambe1a977c712c
diff --git a/src/controllers/user.js b/src/controllers/user.js
index f72eef27d3..0d9d9e6389 100644
--- a/src/controllers/user.js
+++ b/src/controllers/user.js
@@ -117,8 +117,8 @@ userController.exportPosts = function (req, res, next) {
return next(err);
}
- // Convert newlines in content
- posts = posts.map(function (post) {
+ // Remove empty post references and convert newlines in content
+ posts = posts.filter(Boolean).map(function (post) {
post.content = '"' + post.content.replace(/\n/g, '\\n').replace(/"/g, '\\"') + '"';
return post;
});