1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2024-12-27 21:35:41 +00:00

Unescape + to space correctly

This commit is contained in:
King_DuckZ 2017-04-06 22:57:44 +01:00
parent 33c52b88d5
commit fa33944919
4 changed files with 14 additions and 2 deletions

View file

@ -147,7 +147,7 @@ namespace tawashi {
const auto urlencoded_values = split_env_vars(m_cgi_env[CGIVars::QUERY_STRING]); const auto urlencoded_values = split_env_vars(m_cgi_env[CGIVars::QUERY_STRING]);
retval.reserve(urlencoded_values.size()); retval.reserve(urlencoded_values.size());
for (auto& itm : urlencoded_values) { for (auto& itm : urlencoded_values) {
retval[m_curl.url_unescape(itm.first)] = m_curl.url_unescape(itm.second); retval[unescape_string(m_curl, itm.first)] = unescape_string(m_curl, itm.second);
} }
return retval; return retval;
} }

View file

@ -34,7 +34,7 @@ namespace tawashi {
CurlWrapper curl; CurlWrapper curl;
for (auto& itm : split_env_vars(original_data)) { for (auto& itm : split_env_vars(original_data)) {
map[curl.url_unescape(itm.first)] = curl.url_unescape(itm.second); map[unescape_string(curl, itm.first)] = unescape_string(curl, itm.second);
} }
} }

View file

@ -2,6 +2,7 @@
#include <curl/curl.h> #include <curl/curl.h>
#include <cassert> #include <cassert>
#include <ciso646> #include <ciso646>
#include <algorithm>
#if !defined(NDEBUG) #if !defined(NDEBUG)
# define CURL_WRAPPER_VERBOSE # define CURL_WRAPPER_VERBOSE
@ -65,6 +66,15 @@ namespace tawashi {
} }
} //unnamed namespace } //unnamed namespace
std::string unescape_string (const CurlWrapper& parCurl, const boost::string_ref& parString) {
if (parString.empty())
return std::string();
std::string new_value(parString.data(), parString.size());
std::replace(new_value.begin(), new_value.end(), '+', ' ');
return parCurl.url_unescape(new_value);
}
CurlWrapper::CurlWrapper() : CurlWrapper::CurlWrapper() :
m_curl(get_new_curl()) m_curl(get_new_curl())
{ {

View file

@ -21,4 +21,6 @@ namespace tawashi {
private: private:
CurlPtr m_curl; CurlPtr m_curl;
}; };
std::string unescape_string (const CurlWrapper& parCurl, const boost::string_ref& parString);
} //namespace tawashi } //namespace tawashi