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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/api/mime_handler_private/mime_handler_private.h" 5 #include "extensions/browser/api/mime_handler_private/mime_handler_private.h"
6 6
7 #include "base/strings/string_util.h"
7 #include "content/public/browser/stream_handle.h" 8 #include "content/public/browser/stream_handle.h"
8 #include "content/public/browser/stream_info.h" 9 #include "content/public/browser/stream_info.h"
9 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" 10 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h"
10 #include "extensions/common/constants.h" 11 #include "extensions/common/constants.h"
11 #include "net/http/http_response_headers.h" 12 #include "net/http/http_response_headers.h"
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/map.h" 13 #include "third_party/mojo/src/mojo/public/cpp/bindings/map.h"
13 14
14 namespace extensions { 15 namespace extensions {
15 namespace { 16 namespace {
16 17
17 mojo::Map<mojo::String, mojo::String> CreateResponseHeadersMap( 18 mojo::Map<mojo::String, mojo::String> CreateResponseHeadersMap(
18 const net::HttpResponseHeaders* headers) { 19 const net::HttpResponseHeaders* headers) {
19 std::map<std::string, std::string> result; 20 std::map<std::string, std::string> result;
20 if (!headers) 21 if (!headers)
21 return mojo::Map<mojo::String, mojo::String>::From(result); 22 return mojo::Map<mojo::String, mojo::String>::From(result);
22 23
23 void* iter = nullptr; 24 void* iter = nullptr;
24 std::string header_name; 25 std::string header_name;
25 std::string header_value; 26 std::string header_value;
26 while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) { 27 while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) {
28 // mojo strings must be UTF-8 and headers might not be, so drop any headers
29 // that aren't ASCII. The PDF plugin does not use any headers with non-ASCII
30 // names and non-ASCII values are never useful for the headers the plugin
31 // does use.
raymes 2015/04/21 01:00:07 What would be the correct fix? Should we file a bu
Sam McNally 2015/04/21 03:18:55 Added a TODO and mentioned it in the mojom and idl
32 if (!base::IsStringASCII(header_name) || !base::IsStringASCII(header_value))
33 continue;
27 auto& current_value = result[header_name]; 34 auto& current_value = result[header_name];
28 if (!current_value.empty()) 35 if (!current_value.empty())
29 current_value += ", "; 36 current_value += ", ";
30 current_value += header_value; 37 current_value += header_value;
31 } 38 }
32 return mojo::Map<mojo::String, mojo::String>::From(result); 39 return mojo::Map<mojo::String, mojo::String>::From(result);
33 } 40 }
34 41
35 } // namespace 42 } // namespace
36 43
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 const content::StreamInfo* info = stream.stream_info(); 97 const content::StreamInfo* info = stream.stream_info();
91 result->mime_type = info->mime_type; 98 result->mime_type = info->mime_type;
92 result->original_url = info->original_url.spec(); 99 result->original_url = info->original_url.spec();
93 result->stream_url = info->handle->GetURL().spec(); 100 result->stream_url = info->handle->GetURL().spec();
94 result->response_headers = 101 result->response_headers =
95 extensions::CreateResponseHeadersMap(info->response_headers.get()); 102 extensions::CreateResponseHeadersMap(info->response_headers.get());
96 return result.Pass(); 103 return result.Pass();
97 } 104 }
98 105
99 } // namespace mojo 106 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698