Fixed problem with invalid requests including spaces in URL path
This commit is contained in:
parent
24bb1387d6
commit
40db42108f
@ -4204,7 +4204,7 @@ inline void Server::stop() {
|
|||||||
inline bool Server::parse_request_line(const char *s, Request &req) {
|
inline bool Server::parse_request_line(const char *s, Request &req) {
|
||||||
const static std::regex re(
|
const static std::regex re(
|
||||||
"(GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI) "
|
"(GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI) "
|
||||||
"(([^?]+)(?:\\?(.*?))?) (HTTP/1\\.[01])\r\n");
|
"(([^? ]+)(?:\\?([^ ]*?))?) (HTTP/1\\.[01])\r\n");
|
||||||
|
|
||||||
std::cmatch m;
|
std::cmatch m;
|
||||||
if (std::regex_match(s, m, re)) {
|
if (std::regex_match(s, m, re)) {
|
||||||
|
@ -3004,6 +3004,12 @@ TEST(ServerRequestParsingTest, InvalidHeaderTextWithExtraCR) {
|
|||||||
"Content-Type: text/plain\r\n\r");
|
"Content-Type: text/plain\r\n\r");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(ServerRequestParsingTest, InvalidSpaceInURL) {
|
||||||
|
std::string out;
|
||||||
|
test_raw_request("GET /h i HTTP/1.1\r\n\r\n", &out);
|
||||||
|
EXPECT_EQ("HTTP/1.1 400 Bad Request", out.substr(0, 24));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(ServerStopTest, StopServerWithChunkedTransmission) {
|
TEST(ServerStopTest, StopServerWithChunkedTransmission) {
|
||||||
Server svr;
|
Server svr;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user