From 7e309850efebbdf9afac73155487318cad39b64b Mon Sep 17 00:00:00 2001 From: Mystikfluu Date: Sun, 3 Jul 2022 21:34:22 +0200 Subject: [PATCH] add another escaping function for another characterset --- js/htmlescape.js | 8 ++++++++ js/posts.js | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/js/htmlescape.js b/js/htmlescape.js index 6a4faf2..042a016 100644 --- a/js/htmlescape.js +++ b/js/htmlescape.js @@ -35,3 +35,11 @@ const unes = { const cape = m => unes[m]; const unescape = un => replace.call(un, es, cape); + +function escape_special(str) { + return str.replace("\\","\\\\").replace("`","\\`") +} + +function unescape_special(str) { + return str.replace("\\\\","\\").replace("\\`","`") +} diff --git a/js/posts.js b/js/posts.js index bbffe76..5bf3dc7 100644 --- a/js/posts.js +++ b/js/posts.js @@ -112,7 +112,7 @@ async function createPost(username,text,time,specialtext,postid,isbot,reply_id) } newP.appendChild(spacerTextNode()) // |\>.Reply to this Post` + newP.innerHTML += `` if(reply_id != 0) { try { @@ -182,7 +182,7 @@ async function main(){ function reply(username,postid,posttext) { document.getElementById("reply").style = "" document.getElementById("reply_username").innerText = username - document.getElementById("reply_text").innerHTML = filterPost(unescape(posttext.replace("\\\\","\\").replace("\\`","`"))) + document.getElementById("reply_text").innerHTML = filterPost(unescape(unescape_special(unescape_special(posttext)))) reply_id = postid }