Modify urlDecode() method

This commit is contained in:
antao 2019-02-02 13:26:19 +08:00
parent 7b6211f2ce
commit e77b558a71
2 changed files with 4 additions and 3 deletions

View File

@ -443,8 +443,8 @@ std::string urlDecode(const char *begin, const char *end)
if (!((hex >= 48 && hex <= 57) || //0-9
(hex >= 97 && hex <= 122) || //a-z
(hex >= 65 && hex <= 90) || //A-Z
//一些特殊符号及保留字[$-_.+!*'(),] [$&+,/:;=?@]
hex == 0x21 || hex == 0x24 || hex == 0x26 || hex == 0x27 || hex == 0x28 || hex == 0x29 || hex == 0x2a || hex == 0x2b || hex == 0x2c || hex == 0x2d || hex == 0x2e || hex == 0x2f || hex == 0x3A || hex == 0x3B || hex == 0x3D || hex == 0x3f || hex == 0x40 || hex == 0x5f))
//一些特殊符号及保留字[$-_.+!*'(),] [$&+,/:;?@]
hex == 0x21 || hex == 0x24 || hex == 0x26 || hex == 0x27 || hex == 0x28 || hex == 0x29 || hex == 0x2a || hex == 0x2b || hex == 0x2c || hex == 0x2d || hex == 0x2e || hex == 0x2f || hex == 0x3A || hex == 0x3B || hex == 0x3f || hex == 0x40 || hex == 0x5f))
{
result += char(hex);
i += 2;

View File

@ -8,6 +8,7 @@ int main()
std::cout << output << std::endl;
auto output2 = drogon::urlDecode(output);
std::cout << output2 << std::endl;
std::cout << drogon::urlDecode("k2%3D%E5%AE%89&k1%3D1");
std::cout << drogon::urlEncode("k2=安&k1=1") << std::endl;
std::cout << drogon::urlDecode("k2%3D%E5%AE%89&k1%3D1") << std::endl;
return 0;
}