From e77b558a71e5d1bf59a3e453bbfe03d0aac7de1c Mon Sep 17 00:00:00 2001 From: antao Date: Sat, 2 Feb 2019 13:26:19 +0800 Subject: [PATCH] Modify urlDecode() method --- lib/src/Utilities.cc | 4 ++-- lib/tests/UrlCodecTest.cc | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/src/Utilities.cc b/lib/src/Utilities.cc index b27583dc..8e8b21a7 100755 --- a/lib/src/Utilities.cc +++ b/lib/src/Utilities.cc @@ -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; diff --git a/lib/tests/UrlCodecTest.cc b/lib/tests/UrlCodecTest.cc index dbff3633..89cc3332 100644 --- a/lib/tests/UrlCodecTest.cc +++ b/lib/tests/UrlCodecTest.cc @@ -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; } \ No newline at end of file