Loading src/http.cpp +24 −10 Changes for src/http.cpp: 24 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -1437,18 +1437,32 @@ const char *libhttppp::HttpForm::getContentType(){ return _ContentType; } const char *codetable[][2]={ {" " ,"+"}, {"%","%25"}, {"&","%26"}, {"=","%3D}"}, {"@","%40"} }; void libhttppp::HttpForm::urlEncode(const std::string &in,std::string &out){ for (auto i = in.begin(), nd = in.end(); i < nd; ++i) { auto c = ( *i ); for (size_t i = 0; i < in.length(); ++i) { bool encoded = false; switch(c) { case '+': out+="%2B"; break; default: out.push_back(c); // Correct size calculation for the inner loop for (size_t ii = 0; ii < sizeof(codetable) / sizeof(codetable[0]); ++ii) { // Correct check for single-character match if (in[i] == codetable[ii][0][0]) { out += codetable[ii][1]; encoded = true; // Flag that we handled the character break; // Stop checking other entries and move to the next 'i' } } // If we didn't find a match in the table, append the character as is if (!encoded) { out += in[i]; } } } Loading Loading
src/http.cpp +24 −10 Changes for src/http.cpp: 24 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -1437,18 +1437,32 @@ const char *libhttppp::HttpForm::getContentType(){ return _ContentType; } const char *codetable[][2]={ {" " ,"+"}, {"%","%25"}, {"&","%26"}, {"=","%3D}"}, {"@","%40"} }; void libhttppp::HttpForm::urlEncode(const std::string &in,std::string &out){ for (auto i = in.begin(), nd = in.end(); i < nd; ++i) { auto c = ( *i ); for (size_t i = 0; i < in.length(); ++i) { bool encoded = false; switch(c) { case '+': out+="%2B"; break; default: out.push_back(c); // Correct size calculation for the inner loop for (size_t ii = 0; ii < sizeof(codetable) / sizeof(codetable[0]); ++ii) { // Correct check for single-character match if (in[i] == codetable[ii][0][0]) { out += codetable[ii][1]; encoded = true; // Flag that we handled the character break; // Stop checking other entries and move to the next 'i' } } // If we didn't find a match in the table, append the character as is if (!encoded) { out += in[i]; } } } Loading