File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -2413,6 +2413,7 @@ inline bool is_valid_path(const std::string &path) {
24132413 // Read component
24142414 auto beg = i;
24152415 while (i < path.size () && path[i] != ' /' ) {
2416+ if (path[i] == ' \0 ' ) { return false ; }
24162417 i++;
24172418 }
24182419
Original file line number Diff line number Diff line change @@ -71,6 +71,15 @@ TEST(DecodeURLTest, PercentCharacter) {
7171 R"( descrip=Gastos áéíóúñÑ 6)" );
7272}
7373
74+ TEST (DecodeURLTest, PercentCharacterNUL) {
75+ string expected;
76+ expected.push_back (' x' );
77+ expected.push_back (' \0 ' );
78+ expected.push_back (' x' );
79+
80+ EXPECT_EQ (detail::decode_url (" x%00x" , false ), expected);
81+ }
82+
7483TEST (EncodeQueryParamTest, ParseUnescapedChararactersTest) {
7584 string unescapedCharacters = " -_.!~*'()" ;
7685
@@ -2482,6 +2491,12 @@ TEST_F(ServerTest, GetMethodInvalidMountPath) {
24822491 EXPECT_EQ (StatusCode::NotFound_404, res->status );
24832492}
24842493
2494+ TEST_F (ServerTest, GetMethodEmbeddedNUL) {
2495+ auto res = cli_.Get (" /mount/dir/test.html%00.js" );
2496+ ASSERT_TRUE (res);
2497+ EXPECT_EQ (StatusCode::NotFound_404, res->status );
2498+ }
2499+
24852500TEST_F (ServerTest, GetMethodOutOfBaseDirMount) {
24862501 auto res = cli_.Get (" /mount/../www2/dir/test.html" );
24872502 ASSERT_TRUE (res);
You can’t perform that action at this time.
0 commit comments