summaryrefslogtreecommitdiffhomepage
path: root/weblog.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-02-11 16:04:35 +0100
committerRoland Reichwein <mail@reichwein.it>2023-02-11 16:04:35 +0100
commit92a14d375c8cd9dabc32ccb6dcbdf83321af535f (patch)
tree5a0c22d993199f8fa0de1d18b78d5209ca9f4c81 /weblog.cpp
parentdf5e04b2dafde8ff3c87ba8412a9a728f8b24b7d (diff)
Added config
Diffstat (limited to 'weblog.cpp')
-rw-r--r--weblog.cpp49
1 files changed, 8 insertions, 41 deletions
diff --git a/weblog.cpp b/weblog.cpp
index cc2be34..7842ac3 100644
--- a/weblog.cpp
+++ b/weblog.cpp
@@ -2,6 +2,7 @@
#include "libreichwein/mime.h"
#include "libreichwein/stringhelper.h"
+#include "libreichwein/url.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
@@ -322,36 +323,6 @@ namespace {
}
}
- std::string urlDecode(std::string s)
- {
- std::string result;
-
- size_t pos = 0;
- while (pos < s.size()) {
- char c {s[pos]};
- if (c == '+') {
- result += ' ';
- } else if (c == '%' && pos + 2 < s.size()) {
- try {
- int i = stoi(s.substr(pos + 1, 2), 0, 16);
- if (i < 0 || i > 255)
- return result;
-
- result += static_cast<char>(i);
- } catch (...) {
- return result;
- }
-
- pos += 2;
- } else {
- result += c;
- }
- pos++;
- }
-
- return result;
- }
-
std::unordered_map<std::string, std::string> SplitQueryString(std::string& s)
{
std::unordered_map<std::string, std::string> result;
@@ -362,7 +333,7 @@ namespace {
for (auto i: list) {
size_t apos = i.find('=');
if (apos != i.npos) {
- result[urlDecode(i.substr(0, apos))] = urlDecode(i.substr(apos + 1));
+ result[Reichwein::URL::urlDecode(i.substr(0, apos))] = Reichwein::URL::urlDecode(i.substr(apos + 1));
}
}
}
@@ -374,22 +345,17 @@ namespace {
} // anonymous namespace
-std::string weblog_plugin::name()
-{
- return "weblog";
-}
-
-weblog_plugin::weblog_plugin()
+Weblog::Weblog()
{
//std::cout << "Plugin constructor" << std::endl;
}
-weblog_plugin::~weblog_plugin()
+Weblog::~Weblog()
{
//std::cout << "Plugin destructor" << std::endl;
}
-std::string weblog_plugin::generate_page(
+std::string Weblog::generate_page(
std::function<std::string(const std::string& key)>& GetServerParam,
std::function<std::string(const std::string& key)>& GetRequestParam, // request including body (POST...)
std::function<void(const std::string& key, const std::string& value)>& SetResponseHeader // to be added to result string
@@ -450,7 +416,8 @@ std::string weblog_plugin::generate_page(
}
}
-bool weblog_plugin::has_own_authentication()
+void Weblog::run(int argc, char* argv[])
{
- return false;
+ return 0;
}
+