Skip to content

Commit f41e7eb

Browse files
committed
Add unit test for a redirect to an url with query parameters that contain a '+'
1 parent 9db1e5f commit f41e7eb

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/test.cc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9942,6 +9942,37 @@ TEST(RedirectTest, RedirectToUrlWithQueryParameters) {
99429942
}
99439943
}
99449944

9945+
TEST(RedirectTest, RedirectToUrlWithPlusInQueryParameters) {
9946+
Server svr;
9947+
9948+
svr.Get("/", [](const Request & /*req*/, Response &res) {
9949+
res.set_redirect(R"(/hello?key=AByz09+~-._%20%26%3F%C3%BC%2B)");
9950+
});
9951+
9952+
svr.Get("/hello", [](const Request &req, Response &res) {
9953+
res.set_content(req.get_param_value("key"), "text/plain");
9954+
});
9955+
9956+
auto thread = std::thread([&]() { svr.listen(HOST, PORT); });
9957+
auto se = detail::scope_exit([&] {
9958+
svr.stop();
9959+
thread.join();
9960+
ASSERT_FALSE(svr.is_running());
9961+
});
9962+
9963+
svr.wait_until_ready();
9964+
9965+
{
9966+
Client cli(HOST, PORT);
9967+
cli.set_follow_location(true);
9968+
9969+
auto res = cli.Get("/");
9970+
ASSERT_TRUE(res);
9971+
EXPECT_EQ(StatusCode::OK_200, res->status);
9972+
EXPECT_EQ("AByz09 ~-._ &?ü+", res->body);
9973+
}
9974+
}
9975+
99459976
TEST(VulnerabilityTest, CRLFInjection) {
99469977
Server svr;
99479978

0 commit comments

Comments
 (0)