| OLD | NEW |
| 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 "core/frame/SubresourceIntegrity.h" | 5 #include "core/frame/SubresourceIntegrity.h" |
| 6 | 6 |
| 7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
| 10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // [algorithm]-[hash] OR [algorithm]-[hash]?[options] | 295 // [algorithm]-[hash] OR [algorithm]-[hash]?[options] |
| 296 // ^ ^ ^ | 296 // ^ ^ ^ |
| 297 // position/end position end | 297 // position/end position end |
| 298 bool SubresourceIntegrity::parseDigest(const UChar*& position, | 298 bool SubresourceIntegrity::parseDigest(const UChar*& position, |
| 299 const UChar* end, | 299 const UChar* end, |
| 300 String& digest) { | 300 String& digest) { |
| 301 const UChar* begin = position; | 301 const UChar* begin = position; |
| 302 skipWhile<UChar, isIntegrityCharacter>(position, end); | 302 skipWhile<UChar, isIntegrityCharacter>(position, end); |
| 303 | 303 |
| 304 if (position == begin || (position != end && *position != '?')) { | 304 if (position == begin || (position != end && *position != '?')) { |
| 305 digest = emptyString(); | 305 digest = emptyString; |
| 306 return false; | 306 return false; |
| 307 } | 307 } |
| 308 | 308 |
| 309 // We accept base64url encoding, but normalize to "normal" base64 internally: | 309 // We accept base64url encoding, but normalize to "normal" base64 internally: |
| 310 digest = normalizeToBase64(String(begin, position - begin)); | 310 digest = normalizeToBase64(String(begin, position - begin)); |
| 311 return true; | 311 return true; |
| 312 } | 312 } |
| 313 | 313 |
| 314 SubresourceIntegrity::IntegrityParseResult | 314 SubresourceIntegrity::IntegrityParseResult |
| 315 SubresourceIntegrity::parseIntegrityAttribute( | 315 SubresourceIntegrity::parseIntegrityAttribute( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 metadataSet.insert(integrityMetadata.toPair()); | 418 metadataSet.insert(integrityMetadata.toPair()); |
| 419 } | 419 } |
| 420 | 420 |
| 421 if (metadataSet.size() == 0 && error) | 421 if (metadataSet.size() == 0 && error) |
| 422 return IntegrityParseNoValidResult; | 422 return IntegrityParseNoValidResult; |
| 423 | 423 |
| 424 return IntegrityParseValidResult; | 424 return IntegrityParseValidResult; |
| 425 } | 425 } |
| 426 | 426 |
| 427 } // namespace blink | 427 } // namespace blink |
| OLD | NEW |