1
0
mirror of synced 2025-04-20 11:47:43 +03:00

Fixed decode problem with form-urlencoded data.

This commit is contained in:
yhirose 2015-07-13 15:42:21 -04:00
parent 62f824e204
commit cb473e8534

View File

@ -30,6 +30,9 @@
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#undef min
#undef max
typedef SOCKET socket_t; typedef SOCKET socket_t;
#else #else
#include <pthread.h> #include <pthread.h>
@ -579,7 +582,7 @@ inline void parse_query_text(const std::string& s, Map& params)
val.assign(b, e); val.assign(b, e);
} }
}); });
params[key] = val; params[key] = detail::decode_url(val);
}); });
} }
@ -742,7 +745,7 @@ inline bool Server::read_request_line(FILE* fp, Request& req)
// Parse query text // Parse query text
auto len = std::distance(m[3].first, m[3].second); auto len = std::distance(m[3].first, m[3].second);
if (len > 0) { if (len > 0) {
detail::parse_query_text(detail::decode_url(m[3]), req.params); detail::parse_query_text(m[3], req.params);
} }
return true; return true;
@ -815,8 +818,9 @@ inline void Server::process_request(FILE* fp_read, FILE* fp_write)
if (!detail::read_content(req, fp_read)) { if (!detail::read_content(req, fp_read)) {
return; return;
} }
if (req.get_header_value("Content-Type") == "application/x-www-form-urlencoded") { static std::string type = "application/x-www-form-urlencoded";
detail::parse_query_text(detail::decode_url(req.body), req.params); if (!req.get_header_value("Content-Type").compare(0, type.size(), type)) {
detail::parse_query_text(req.body, req.params);
} }
} }