Code format

This commit is contained in:
yhirose 2020-12-19 20:14:53 -05:00
parent 40db42108f
commit e9c6c6e609
2 changed files with 59 additions and 65 deletions

View File

@ -192,6 +192,7 @@ using socket_t = int;
#include <fcntl.h>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
@ -203,7 +204,6 @@ using socket_t = int;
#include <string>
#include <sys/stat.h>
#include <thread>
#include <iomanip>
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
#include <openssl/err.h>
@ -1463,20 +1463,13 @@ inline std::string encode_query_param(const std::string &value){
escaped << std::hex;
for (char const &c : value) {
if (std::isalnum(c) ||
c == '-' ||
c == '_' ||
c == '.' ||
c == '!' ||
c == '~' ||
c == '*' ||
c == '\'' ||
c == '(' ||
c == ')') {
if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c == '!' ||
c == '~' || c == '*' || c == '\'' || c == '(' || c == ')') {
escaped << c;
} else {
escaped << std::uppercase;
escaped << '%' << std::setw(2) << static_cast<int>(static_cast<unsigned char>(c));
escaped << '%' << std::setw(2)
<< static_cast<int>(static_cast<unsigned char>(c));
escaped << std::nouppercase;
}
}

View File

@ -55,7 +55,8 @@ TEST(EncodeQueryParamTest, ParseUnescapedChararactersTest){
TEST(EncodeQueryParamTest, ParseReservedCharactersTest) {
string reservedCharacters = ";,/?:@&=+$";
EXPECT_EQ(detail::encode_query_param(reservedCharacters), "%3B%2C%2F%3F%3A%40%26%3D%2B%24");
EXPECT_EQ(detail::encode_query_param(reservedCharacters),
"%3B%2C%2F%3F%3A%40%26%3D%2B%24");
}
TEST(TrimTests, TrimStringTests) {