From 53a9517d5436252a3687dc82d65a6f8623c4270d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 12 Jun 2020 10:29:07 -0400 Subject: [PATCH] fix: crash in export posts if post content is undefined --- src/controllers/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/user.js b/src/controllers/user.js index 3980210efc..3c55a5f642 100644 --- a/src/controllers/user.js +++ b/src/controllers/user.js @@ -91,7 +91,7 @@ userController.exportPosts = async function (req, res) { let postData = await posts.getPostsData(pids); // Remove empty post references and convert newlines in content postData = postData.filter(Boolean).map(function (post) { - post.content = '"' + post.content.replace(/\n/g, '\\n').replace(/"/g, '\\"') + '"'; + post.content = '"' + String(post.content || '').replace(/\n/g, '\\n').replace(/"/g, '\\"') + '"'; return post; }); payload = payload.concat(postData);