You've already forked cpp-httplib
Fix query parsing issues (#629)
* Fix parsing to parse query string with single space char. When passed ' ' as a query string, the server crashes cause of illegal memory access done in httplib::detail::split. Have added checks to make sure the split function has a valid string with length > 0. * Fix parsing to parse query string with single space char.
This commit is contained in:
18
test/test.cc
18
test/test.cc
@ -66,6 +66,24 @@ TEST(SplitTest, ParseQueryString) {
|
||||
EXPECT_EQ("val3", dic.find("key3")->second);
|
||||
}
|
||||
|
||||
TEST(SplitTest, ParseInvalidQueryTests) {
|
||||
|
||||
{
|
||||
string s = " ";
|
||||
Params dict;
|
||||
detail::parse_query_text(s, dict);
|
||||
EXPECT_TRUE(dict.empty());
|
||||
}
|
||||
|
||||
{
|
||||
string s = " = =";
|
||||
Params dict;
|
||||
detail::parse_query_text(s, dict);
|
||||
EXPECT_TRUE(dict.empty());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(ParseQueryTest, ParseQueryString) {
|
||||
string s = "key1=val1&key2=val2&key3=val3";
|
||||
Params dic;
|
||||
|
Reference in New Issue
Block a user