Sanitise html

This commit is contained in:
2026-07-20 17:49:29 +10:00
parent c3e39d5714
commit d015b12277

View File

@@ -1,20 +1,23 @@
#include "post.h"
#include <memory>
#include <regex>
#include <sstream>
#include <string>
#include <ctime>
#include <maddy/parser.h>
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<maddy::Parser> parser = std::make_shared<maddy::Parser>();
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<maddy::Parser> parser = std::make_shared<maddy::Parser>();
content = parser->Parse(input);
}