From d015b1227734a69271ef954dcceb2cf00d47611d Mon Sep 17 00:00:00 2001 From: Maxwell Jeffress Date: Mon, 20 Jul 2026 17:49:29 +1000 Subject: [PATCH] Sanitise html --- server/src/post.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/src/post.cpp b/server/src/post.cpp index 4061e73..7840318 100644 --- a/server/src/post.cpp +++ b/server/src/post.cpp @@ -1,20 +1,23 @@ #include "post.h" #include +#include #include #include #include #include +std::regex tags("<[^<]*>"); + Post::Post(const std::string& contentin, const std::string& user) : user(user), time(std::time(nullptr)) { // parse the post content markdown - std::stringstream input(contentin); + std::stringstream input(std::regex_replace(contentin, tags, "")); std::shared_ptr parser = std::make_shared(); content = parser->Parse(input); } Post::Post(const std::string& contentin, uint64_t user) : userId(user), time(std::time(nullptr)) { // parse the post content markdown - std::stringstream input(contentin); + std::stringstream input(std::regex_replace(contentin, tags, "")); std::shared_ptr parser = std::make_shared(); content = parser->Parse(input); }