OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Canonicalizers for random bits that aren't big enough for their own files. | 5 // Canonicalizers for random bits that aren't big enough for their own files. |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "url/url_canon.h" | 9 #include "url/url_canon.h" |
10 #include "url/url_canon_internal.h" | 10 #include "url/url_canon_internal.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 } | 81 } |
82 | 82 |
83 template<typename CHAR, typename UCHAR> | 83 template<typename CHAR, typename UCHAR> |
84 bool DoScheme(const CHAR* spec, | 84 bool DoScheme(const CHAR* spec, |
85 const Component& scheme, | 85 const Component& scheme, |
86 CanonOutput* output, | 86 CanonOutput* output, |
87 Component* out_scheme) { | 87 Component* out_scheme) { |
88 if (scheme.len <= 0) { | 88 if (scheme.len <= 0) { |
89 // Scheme is unspecified or empty, convert to empty by appending a colon. | 89 // Scheme is unspecified or empty, convert to empty by appending a colon. |
90 *out_scheme = Component(output->length(), 0); | 90 *out_scheme = Component(output->length(), 0); |
91 output->push_back(':'); | 91 output->push_back(':'); |
Peter Kasting
2016/09/29 04:54:12
What happens if we don't bother to insert a colon?
| |
92 return true; | 92 return false; |
93 } | 93 } |
94 | 94 |
95 // The output scheme starts from the current position. | 95 // The output scheme starts from the current position. |
96 out_scheme->begin = output->length(); | 96 out_scheme->begin = output->length(); |
97 | 97 |
98 // Danger: it's important that this code does not strip any characters; | 98 // Danger: it's important that this code does not strip any characters; |
99 // it only emits the canonical version (be it valid or escaped) for each | 99 // it only emits the canonical version (be it valid or escaped) for each |
100 // of the input characters. Stripping would put it out of sync with | 100 // of the input characters. Stripping would put it out of sync with |
101 // FindAndCompareScheme, which could cause some security checks on | 101 // FindAndCompareScheme, which could cause some security checks on |
102 // schemes to be incorrect. | 102 // schemes to be incorrect. |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 } | 358 } |
359 | 359 |
360 void CanonicalizeRef(const base::char16* spec, | 360 void CanonicalizeRef(const base::char16* spec, |
361 const Component& ref, | 361 const Component& ref, |
362 CanonOutput* output, | 362 CanonOutput* output, |
363 Component* out_ref) { | 363 Component* out_ref) { |
364 DoCanonicalizeRef<base::char16, base::char16>(spec, ref, output, out_ref); | 364 DoCanonicalizeRef<base::char16, base::char16>(spec, ref, output, out_ref); |
365 } | 365 } |
366 | 366 |
367 } // namespace url | 367 } // namespace url |
OLD | NEW |