This repository was archived by the owner on Apr 10, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,21 @@ TEST_F(MetaTagFilterTest, TestTags) {
67
67
<< *values[0 ];
68
68
}
69
69
70
+ const char kMetaTagDocInvalidAttribute [] =
71
+ " <html><head>"
72
+ " <meta http-equiv=\" Content-Type\" content=\" text/html;"
73
+ " charset=U\r\n TF-8\" >"
74
+ " </head><body></body></html>" ;
75
+
76
+ TEST_F (MetaTagFilterTest, TestRejectInvalidAttribute) {
77
+ headers ()->RemoveAll (HttpAttributes::kContentType );
78
+ ValidateNoChanges (" convert_tags_invalid_attribute" ,
79
+ kMetaTagDocInvalidAttribute );
80
+ ConstStringStarVector values;
81
+ EXPECT_FALSE (headers ()->Lookup (HttpAttributes::kContentType , &values));
82
+ ASSERT_EQ (0 , values.size ());
83
+ }
84
+
70
85
const char kMetaTagDoubleDoc [] =
71
86
" <html><head>"
72
87
" <meta http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >"
Original file line number Diff line number Diff line change @@ -321,6 +321,12 @@ bool ResponseHeaders::CombineContentTypes(const StringPiece& orig,
321
321
}
322
322
323
323
bool ResponseHeaders::MergeContentType (const StringPiece& content_type) {
324
+ for (size_t i = 0 ; i < content_type.size (); i++) {
325
+ if (!IsNonControlAscii (content_type[i])) {
326
+ return false ;
327
+ }
328
+ }
329
+
324
330
bool ret = false ;
325
331
ConstStringStarVector old_values;
326
332
Lookup (HttpAttributes::kContentType , &old_values);
Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ class ResponseHeaders : public Headers<HttpResponseHeaders> {
75
75
76
76
// Merge the new content_type with what is already in the headers.
77
77
// Returns true if the existing content-type header was changed.
78
+ // If the new content_type contains non-printable characters, the
79
+ // change will be rejected silently (and false will be returned).
78
80
bool MergeContentType (const StringPiece& content_type);
79
81
80
82
// Merge headers. Replaces all headers specified both here and in
You can’t perform that action at this time.
0 commit comments