mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-05 03:02:06 +00:00
Fix request arguments not properly handled (#661)
This commit is contained in:
12 files changed
+177
-543
No files matched your search
@@ -21,13 +21,12 @@ enum
|
||||
INIREADER_EXCEPTION_NONE
|
||||
};
|
||||
|
||||
using ini_data_struct = std::map<std::string, std::multimap<std::string, std::string>>;
|
||||
using string_multimap = std::multimap<std::string, std::string>;
|
||||
using string_array = std::vector<std::string>;
|
||||
using string_size = std::string::size_type;
|
||||
|
||||
class INIReader
|
||||
{
|
||||
using ini_data_struct = std::map<std::string, std::multimap<std::string, std::string>>;
|
||||
using string_multimap = std::multimap<std::string, std::string>;
|
||||
using string_array = std::vector<std::string>;
|
||||
using string_size = std::string::size_type;
|
||||
/**
|
||||
* @brief A simple INI reader which utilize map and vector
|
||||
* to store sections and items, allowing access in logarithmic time.
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "string.h"
|
||||
#include "map_extra.h"
|
||||
|
||||
std::vector<std::string> split(const std::string &s, const std::string &seperator)
|
||||
{
|
||||
@@ -298,6 +299,14 @@ std::string getUrlArg(const std::string &url, const std::string &request)
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string getUrlArg(const string_multimap &url, const std::string &request)
|
||||
{
|
||||
auto it = url.find(request);
|
||||
if(it != url.end())
|
||||
return it->second;
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string replaceAllDistinct(std::string str, const std::string &old_value, const std::string &new_value)
|
||||
{
|
||||
for(std::string::size_type pos(0); pos != std::string::npos; pos += new_value.length())
|
||||
|
||||
@@ -11,6 +11,7 @@ using string = std::string;
|
||||
using string_size = std::string::size_type;
|
||||
using string_array = std::vector<std::string>;
|
||||
using string_map = std::map<std::string, std::string>;
|
||||
using string_multimap = std::multimap<std::string, std::string>;
|
||||
using string_pair_array = std::vector<std::pair<std::string, std::string>>;
|
||||
|
||||
std::vector<std::string> split(const std::string &s, const std::string &seperator);
|
||||
@@ -27,6 +28,7 @@ std::string join(InputIt first, InputIt last, const std::string &delimiter)
|
||||
}
|
||||
|
||||
std::string getUrlArg(const std::string &url, const std::string &request);
|
||||
std::string getUrlArg(const string_multimap &url, const std::string &request);
|
||||
std::string replaceAllDistinct(std::string str, const std::string &old_value, const std::string &new_value);
|
||||
std::string trimOf(const std::string& str, char target, bool before = true, bool after = true);
|
||||
std::string trim(const std::string& str, bool before = true, bool after = true);
|
||||
|
||||
@@ -69,3 +69,17 @@ std::string urlDecode(const std::string& str)
|
||||
}
|
||||
return strTemp;
|
||||
}
|
||||
|
||||
std::string joinArguments(const string_multimap &args)
|
||||
{
|
||||
std::string strTemp;
|
||||
for (auto &p: args)
|
||||
{
|
||||
strTemp += p.first + "=" + urlEncode(p.second) + "&";
|
||||
}
|
||||
if (!strTemp.empty())
|
||||
{
|
||||
strTemp.pop_back();
|
||||
}
|
||||
return strTemp;
|
||||
}
|
||||
@@ -3,7 +3,10 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "utils/string.h"
|
||||
|
||||
std::string urlEncode(const std::string& str);
|
||||
std::string urlDecode(const std::string& str);
|
||||
std::string joinArguments(const string_multimap &args);
|
||||
|
||||
#endif // URLENCODE_H_INCLUDED
|
||||
Reference in new issue
Block a user