1
0
mirror of synced 2025-09-05 13:43:59 +03:00
* Fix #2184, #2185

* Fix build error

* Update

* Update
This commit is contained in:
yhirose
2025-07-29 19:29:37 -04:00
committed by GitHub
parent 8e8a23e3d2
commit c0c36f021d
2 changed files with 232 additions and 65 deletions

View File

@@ -301,9 +301,8 @@ TEST(StartupTest, WSAStartup) {
TEST(DecodePathTest, PercentCharacter) {
EXPECT_EQ(
detail::decode_path(
R"(descrip=Gastos%20%C3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%B1%C3%91%206)",
false),
decode_path_component(
R"(descrip=Gastos%20%C3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%B1%C3%91%206)"),
u8"descrip=Gastos áéíóúñÑ 6");
}
@@ -313,7 +312,7 @@ TEST(DecodePathTest, PercentCharacterNUL) {
expected.push_back('\0');
expected.push_back('x');
EXPECT_EQ(detail::decode_path("x%00x", false), expected);
EXPECT_EQ(decode_path_component("x%00x"), expected);
}
TEST(EncodeQueryParamTest, ParseUnescapedChararactersTest) {
@@ -9942,6 +9941,51 @@ TEST(RedirectTest, RedirectToUrlWithQueryParameters) {
}
}
TEST(RedirectTest, RedirectToUrlWithPlusInQueryParameters) {
Server svr;
svr.Get("/", [](const Request & /*req*/, Response &res) {
res.set_redirect(R"(/hello?key=AByz09+~-._%20%26%3F%C3%BC%2B)");
});
svr.Get("/hello", [](const Request &req, Response &res) {
res.set_content(req.get_param_value("key"), "text/plain");
});
auto thread = std::thread([&]() { svr.listen(HOST, PORT); });
auto se = detail::scope_exit([&] {
svr.stop();
thread.join();
ASSERT_FALSE(svr.is_running());
});
svr.wait_until_ready();
{
Client cli(HOST, PORT);
cli.set_follow_location(true);
auto res = cli.Get("/");
ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::OK_200, res->status);
EXPECT_EQ("AByz09 ~-._ &?ü+", res->body);
}
}
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
TEST(RedirectTest, Issue2185_Online) {
SSLClient client("github.com");
client.set_follow_location(true);
auto res = client.Get("/Coollab-Art/Coollab/releases/download/1.1.1_UI-Scale/"
"Coollab-Windows.zip");
ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::OK_200, res->status);
EXPECT_EQ(9920427U, res->body.size());
}
#endif
TEST(VulnerabilityTest, CRLFInjection) {
Server svr;