forked from chookspace/chookchat
Sanitise html
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user