Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1328)

Unified Diff: net/filter/filter_source_stream.cc

Issue 2753453003: Reject unadvertised encodings (Closed)
Patch Set: Reject unadvertised encodings. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/filter/filter_source_stream.cc
diff --git a/net/filter/filter_source_stream.cc b/net/filter/filter_source_stream.cc
index 603bd703c8e7311744fc74e0ae868a383d0cb518..a2d5a709c3c0f4b37606dc605666e86bbc7715be 100644
--- a/net/filter/filter_source_stream.cc
+++ b/net/filter/filter_source_stream.cc
@@ -17,6 +17,12 @@ namespace net {
namespace {
+const char kDeflate[] = "deflate";
+const char kGZip[] = "gzip";
+const char kSdch[] = "sdch";
+const char kXGZip[] = "x-gzip";
+const char kBrotli[] = "br";
+
const size_t kBufferSize = 32 * 1024;
} // namespace
@@ -67,6 +73,28 @@ std::string FilterSourceStream::Description() const {
return next_type_string + "," + GetTypeAsString();
}
+FilterSourceStream::SourceType FilterSourceStream::ParseEncodingType(
+ const std::string& encoding) {
+ if (encoding.empty()) {
+ return TYPE_NONE;
+ } else if (base::LowerCaseEqualsASCII(encoding, kBrotli)) {
+ return TYPE_BROTLI;
+ } else if (base::LowerCaseEqualsASCII(encoding, kDeflate)) {
+ return TYPE_DEFLATE;
+ } else if (base::LowerCaseEqualsASCII(encoding, kGZip) ||
+ base::LowerCaseEqualsASCII(encoding, kXGZip)) {
+ return TYPE_GZIP;
+ } else if (base::LowerCaseEqualsASCII(encoding, kSdch)) {
+ return TYPE_SDCH;
+ } else {
+ return TYPE_UNKNOWN;
+ }
+}
+
+void FilterSourceStream::ReportContentDecodingRejected(SourceType type) {
+ UMA_HISTOGRAM_ENUMERATION("Net.ContentDecodingRejected", type, TYPE_MAX);
+}
+
int FilterSourceStream::DoLoop(int result) {
DCHECK_NE(STATE_NONE, next_state_);

Powered by Google App Engine
This is Rietveld 408576698