Commit d473b008 authored by Asanka Herath's avatar Asanka Herath Committed by Commit Bot

[net/http] Add a test to HttpContentDisposition that includes a NUL.

While //net's header parser will reject strings with embedded NULs,
HttpCHttpContentDisposition can be invoked directly on some arbitrary
string. It should handle NULs gracefully in this case.

Bug: None
Change-Id: I31b7a89d27ebc01d8311d5fde156672d974543e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857520Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Commit-Queue: Asanka Herath <asanka@chromium.org>
Auto-Submit: Asanka Herath <asanka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705556}
parent fd1bb443
......@@ -499,4 +499,15 @@ TEST(HttpContentDispositionTest, ParseResult) {
}
}
TEST(HttpContentDispositionTest, ContainsNul) {
const char kHeader[] = "filename=ab\0c";
const char kExpectedFilename[] = "ab\0c";
// Note: both header and expected_filename include the trailing NUL.
std::string header{kHeader, sizeof(kHeader)};
std::string expected_filename{kExpectedFilename, sizeof(kExpectedFilename)};
HttpContentDisposition content_disposition(header, "utf-8");
EXPECT_EQ(expected_filename, content_disposition.filename());
}
} // namespace net
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment