From d23c6dff28491333ff5ea092ad564f35390dc9a7 Mon Sep 17 00:00:00 2001 From: julian laplace Date: Fri, 27 Mar 2026 15:14:43 +0100 Subject: fix body encoding --- bucky/app/bucky.js | 14 ++++++++++---- public/assets/js/lib/views/mail/message.js | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 81171f4..3e76e9b 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -92,7 +92,7 @@ var bucky = (module.exports = { res.threads_ids = threads.pluck("id").sort(); res.keywords = _.uniq(threads.pluck("keyword")); next(); - }) + }), ); } else if (query.thread) { db.getThread(query.thread).then((thread) => @@ -110,7 +110,7 @@ var bucky = (module.exports = { res.threads_ids = [query.thread]; res.keywords = [thread.get("keyword")]; next(); - }) + }), ); } else { Promise.all([ @@ -413,7 +413,7 @@ var bucky = (module.exports = { res.sendStatus(404); } db.getTopThreadsForUser(username, limit, offset).then(function ( - top_threads + top_threads, ) { res.topThreads = top_threads; res.topThreads_ids = res.topThreads.pluck("id").sort(); @@ -794,7 +794,7 @@ var bucky = (module.exports = { req.user.get("username"), req.params.box, limit, - offset + offset, ).then(function (messages) { res.messages = messages; res.query = { limit, offset }; @@ -815,6 +815,12 @@ var bucky = (module.exports = { return; } res.message = message; + + // Fix mail body encoding ... + const body = res.message.get("body"); + if (body instanceof Buffer) { + res.message.set("body", body.toString("utf8")); + } next(); }); }, diff --git a/public/assets/js/lib/views/mail/message.js b/public/assets/js/lib/views/mail/message.js index 6ea2274..8ad6c1a 100644 --- a/public/assets/js/lib/views/mail/message.js +++ b/public/assets/js/lib/views/mail/message.js @@ -42,7 +42,7 @@ var MessageView = View.extend({ .replace(/{{subject}}/g, message.subject) .replace(/{{date}}/g, datetime[0]) .replace(/{{time}}/g, datetime[1]) - .replace(/{{body}}/g, tidy_urls(message.body)); + .replace(/{{body}}/g, tidy_urls(message.body || "")); var $t = $(t); if (is_sender) { $t.find(".reply_link").remove(); -- cgit v1.2.3-70-g09d2