From f37d258a8ec36f5c73f58fec144968c977e8b035 Mon Sep 17 00:00:00 2001 From: blankie Date: Thu, 4 Jan 2024 02:10:16 +1100 Subject: [PATCH] Replace \n in raw text to
https://shonk.social/@Sharkey --- htmlhelper.cpp | 6 ++++++ routes/user.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/htmlhelper.cpp b/htmlhelper.cpp index be58afd..3eb1f5f 100644 --- a/htmlhelper.cpp +++ b/htmlhelper.cpp @@ -343,6 +343,12 @@ static Element serialize_post(const httplib::Request& req, const std::string& se blankie::html::HTMLString preprocessed_html = preprocess_html(req, server, post.emojis, post.content); // Workaround for https://vt.social/@a1ba@suya.place/110552480243348878#m if (preprocessed_html.str.find("

") == std::string::npos) { + size_t offset = 0; + while ((offset = preprocessed_html.str.find('\n', offset)) != std::string::npos) { + preprocessed_html.str.replace(offset, 1, "
"); + offset += 4; + } + preprocessed_html.str.reserve(preprocessed_html.str.size() + 3 + 4); preprocessed_html.str.insert(0, "

"); preprocessed_html.str.append("

"); diff --git a/routes/user.cpp b/routes/user.cpp index d298dec..5958034 100644 --- a/routes/user.cpp +++ b/routes/user.cpp @@ -88,6 +88,12 @@ static inline Element user_header(const httplib::Request& req, const std::string blankie::html::HTMLString preprocessed_bio = preprocess_html(req, account.server, account.emojis, account.note_html); // Workaround for https://social.kernel.org/@monsieuricon if (preprocessed_bio.str.find("

") == std::string::npos) { + size_t offset = 0; + while ((offset = preprocessed_bio.str.find('\n', offset)) != std::string::npos) { + preprocessed_bio.str.replace(offset, 1, "
"); + offset += 4; + } + preprocessed_bio.str.reserve(preprocessed_bio.str.size() + 3 + 4); preprocessed_bio.str.insert(0, "

"); preprocessed_bio.str.append("

");