From 4b8f1659c5fe4fc9852dd83fbef7d22a6e3fb273 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 24 Nov 2021 00:27:13 -0500 Subject: [PATCH] Save messages as multipart/mixed with the HTML component in base64 encoding. We probably should rethink this because now we're double-base64-encoding inline images. --- webcit-ng/static/js/view_forum.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/webcit-ng/static/js/view_forum.js b/webcit-ng/static/js/view_forum.js index 56b6a589b..c669a0b39 100644 --- a/webcit-ng/static/js/view_forum.js +++ b/webcit-ng/static/js/view_forum.js @@ -265,14 +265,35 @@ function cancel_post(div_name) { // Save the posted message to the server function save_message(div_name, reply_to_msgnum) { - msg_text = "" + document.getElementById("ctdl-editor-body").innerHTML + "\n"; + + document.body.style.cursor = "wait"; + url = "/ctdl/r/" + escapeHTMLURI(current_room) + "/dummy_name_for_new_message"; + boundary = randomString(20); + + // This converts the message to base64, then splits it into 76-character chunks + encoded_msg_lines = + btoa("" + document.getElementById("ctdl-editor-body").innerHTML + "") + .match(/.{1,76}/g); + + body_text = + "--" + boundary + "\r\n" + + "Content-type: text/html\r\n" + + "Content-transfer-encoding: base64\r\n" + + "\r\n"; + for (var i=0; i