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

Unified Diff: extensions/browser/api/mime_handler_private/mime_handler_private.cc

Issue 1092163004: Ignore non-ASCII headers in the mimeHandlerPrivate API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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: extensions/browser/api/mime_handler_private/mime_handler_private.cc
diff --git a/extensions/browser/api/mime_handler_private/mime_handler_private.cc b/extensions/browser/api/mime_handler_private/mime_handler_private.cc
index b7d557d18015285cb3bb90a542fb863dfdf0bfaa..4b9c5e382d723600598d70f380760f4c3a89ceb5 100644
--- a/extensions/browser/api/mime_handler_private/mime_handler_private.cc
+++ b/extensions/browser/api/mime_handler_private/mime_handler_private.cc
@@ -4,6 +4,7 @@
#include "extensions/browser/api/mime_handler_private/mime_handler_private.h"
+#include "base/strings/string_util.h"
#include "content/public/browser/stream_handle.h"
#include "content/public/browser/stream_info.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
@@ -24,6 +25,15 @@ mojo::Map<mojo::String, mojo::String> CreateResponseHeadersMap(
std::string header_name;
std::string header_value;
while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) {
+ // mojo strings must be UTF-8 and headers might not be, so drop any headers
+ // that aren't ASCII. The PDF plugin does not use any headers with non-ASCII
+ // names and non-ASCII values are never useful for the headers the plugin
+ // does use.
+ //
+ // TODO(sammc): Send as bytes instead of a string and let the client decide
+ // how to decode.
+ if (!base::IsStringASCII(header_name) || !base::IsStringASCII(header_value))
+ continue;
auto& current_value = result[header_name];
if (!current_value.empty())
current_value += ", ";

Powered by Google App Engine
This is Rietveld 408576698