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

Side by Side Diff: Source/core/frame/SubresourceIntegrity.cpp

Issue 798043002: SRI: Accept dashed hash algorithms. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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 | Source/core/frame/SubresourceIntegrityTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/frame/SubresourceIntegrity.h" 6 #include "core/frame/SubresourceIntegrity.h"
7 7
8 #include "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 { 161 {
162 // Any additions or subtractions from this struct should also modify the 162 // Any additions or subtractions from this struct should also modify the
163 // respective entries in the kAlgorithmMap array in checkDigest() as well 163 // respective entries in the kAlgorithmMap array in checkDigest() as well
164 // as the array in algorithmToString(). 164 // as the array in algorithmToString().
165 static const struct { 165 static const struct {
166 const char* prefix; 166 const char* prefix;
167 HashAlgorithm algorithm; 167 HashAlgorithm algorithm;
168 } kSupportedPrefixes[] = { 168 } kSupportedPrefixes[] = {
169 { "sha256", HashAlgorithmSha256 }, 169 { "sha256", HashAlgorithmSha256 },
170 { "sha384", HashAlgorithmSha384 }, 170 { "sha384", HashAlgorithmSha384 },
171 { "sha512", HashAlgorithmSha512 } 171 { "sha512", HashAlgorithmSha512 },
172 { "sha-256", HashAlgorithmSha256 },
jww 2014/12/12 19:11:06 If you're cool with it, I'd rather order the algor
173 { "sha-384", HashAlgorithmSha384 },
174 { "sha-512", HashAlgorithmSha512 }
172 }; 175 };
173 176
174 for (auto& prefix : kSupportedPrefixes) { 177 for (auto& prefix : kSupportedPrefixes) {
175 if (skipToken<UChar>(position, end, prefix.prefix)) { 178 if (skipToken<UChar>(position, end, prefix.prefix)) {
176 algorithm = prefix.algorithm; 179 algorithm = prefix.algorithm;
177 return true; 180 return true;
178 } 181 }
179 } 182 }
180 183
181 return false; 184 return false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 logErrorToConsole("Error parsing 'integrity' attribute ('" + attribute + "'). The digest must be a valid, base64-encoded value.", document); 235 logErrorToConsole("Error parsing 'integrity' attribute ('" + attribute + "'). The digest must be a valid, base64-encoded value.", document);
233 return false; 236 return false;
234 } 237 }
235 238
236 // FIXME: Parse params in order to get content type (e.g. "?ct=application/j avascript") 239 // FIXME: Parse params in order to get content type (e.g. "?ct=application/j avascript")
237 240
238 return true; 241 return true;
239 } 242 }
240 243
241 } // namespace blink 244 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/frame/SubresourceIntegrityTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698