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

Side by Side Diff: third_party/WebKit/Source/platform/network/NetworkUtils.cpp

Issue 2702503002: Block renderer-initiated main frame navigations to data URLs (Closed)
Patch Set: dcheng comments - move checks to FrameLoader Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/network/NetworkUtils.h" 5 #include "platform/network/NetworkUtils.h"
6 6
7 #include "components/mime_util/mime_util.h" 7 #include "components/mime_util/mime_util.h"
8 #include "net/base/data_url.h" 8 #include "net/base/data_url.h"
9 #include "net/base/ip_address.h" 9 #include "net/base/ip_address.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 size_t iter = 0; 98 size_t iter = 0;
99 std::string name; 99 std::string name;
100 std::string value; 100 std::string value;
101 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { 101 while (headers->EnumerateHeaderLines(&iter, &name, &value)) {
102 response.AddHTTPHeaderField(WebString::FromLatin1(name), 102 response.AddHTTPHeaderField(WebString::FromLatin1(name),
103 WebString::FromLatin1(value)); 103 WebString::FromLatin1(value));
104 } 104 }
105 return data; 105 return data;
106 } 106 }
107 107
108 bool IsDataURLMimeTypeSupported(const KURL& url) {
109 std::string utf8_mime_type;
110 std::string utf8_charset;
111 if (net::DataURL::Parse(WebStringToGURL(url.GetString()), &utf8_mime_type,
dcheng 2017/04/19 11:59:49 Hmm... it would be kind of nice if we had a way to
meacer 2017/04/21 01:31:21 Acknowledged. I can file a bug, but there doesn't
112 &utf8_charset, nullptr)) {
113 return mime_util::IsSupportedMimeType(utf8_mime_type);
114 }
115 return false;
116 }
117
108 bool IsRedirectResponseCode(int response_code) { 118 bool IsRedirectResponseCode(int response_code) {
109 return net::HttpResponseHeaders::IsRedirectResponseCode(response_code); 119 return net::HttpResponseHeaders::IsRedirectResponseCode(response_code);
110 } 120 }
111 121
112 } // NetworkUtils 122 } // NetworkUtils
113 123
114 } // namespace blink 124 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698