| OLD | NEW |
| 1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return true; | 111 return true; |
| 112 } | 112 } |
| 113 return false; | 113 return false; |
| 114 } | 114 } |
| 115 | 115 |
| 116 template<typename CHAR> | 116 template<typename CHAR> |
| 117 bool DoFindAndCompareScheme(const CHAR* str, | 117 bool DoFindAndCompareScheme(const CHAR* str, |
| 118 int str_len, | 118 int str_len, |
| 119 const char* compare, | 119 const char* compare, |
| 120 url_parse::Component* found_scheme) { | 120 url_parse::Component* found_scheme) { |
| 121 // Before extracting scheme, canonicalize the URL to remove any whitespace. |
| 122 // This matches the canonicalization done in DoCanonicalize function. |
| 123 url_canon::RawCanonOutputT<CHAR> whitespace_buffer; |
| 124 int spec_len; |
| 125 const CHAR* spec = RemoveURLWhitespace(str, str_len, |
| 126 &whitespace_buffer, &spec_len); |
| 127 |
| 121 url_parse::Component our_scheme; | 128 url_parse::Component our_scheme; |
| 122 if (!url_parse::ExtractScheme(str, str_len, &our_scheme)) { | 129 if (!url_parse::ExtractScheme(spec, spec_len, &our_scheme)) { |
| 123 // No scheme. | 130 // No scheme. |
| 124 if (found_scheme) | 131 if (found_scheme) |
| 125 *found_scheme = url_parse::Component(); | 132 *found_scheme = url_parse::Component(); |
| 126 return false; | 133 return false; |
| 127 } | 134 } |
| 128 if (found_scheme) | 135 if (found_scheme) |
| 129 *found_scheme = our_scheme; | 136 *found_scheme = our_scheme; |
| 130 return CompareSchemeComponent(str, our_scheme, compare); | 137 return CompareSchemeComponent(spec, our_scheme, compare); |
| 131 } | 138 } |
| 132 | 139 |
| 133 template<typename CHAR> | 140 template<typename CHAR> |
| 134 bool DoCanonicalize(const CHAR* in_spec, int in_spec_len, | 141 bool DoCanonicalize(const CHAR* in_spec, int in_spec_len, |
| 135 url_canon::CharsetConverter* charset_converter, | 142 url_canon::CharsetConverter* charset_converter, |
| 136 url_canon::CanonOutput* output, | 143 url_canon::CanonOutput* output, |
| 137 url_parse::Parsed* output_parsed) { | 144 url_parse::Parsed* output_parsed) { |
| 138 // Remove any whitespace from the middle of the relative URL, possibly | 145 // Remove any whitespace from the middle of the relative URL, possibly |
| 139 // copying to the new buffer. | 146 // copying to the new buffer. |
| 140 url_canon::RawCanonOutputT<CHAR> whitespace_buffer; | 147 url_canon::RawCanonOutputT<CHAR> whitespace_buffer; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 return a_begin == a_end && b_begin == b_end; | 476 return a_begin == a_end && b_begin == b_end; |
| 470 } | 477 } |
| 471 | 478 |
| 472 bool LowerCaseEqualsASCII(const char16* a_begin, | 479 bool LowerCaseEqualsASCII(const char16* a_begin, |
| 473 const char16* a_end, | 480 const char16* a_end, |
| 474 const char* b) { | 481 const char* b) { |
| 475 return DoLowerCaseEqualsASCII(a_begin, a_end, b); | 482 return DoLowerCaseEqualsASCII(a_begin, a_end, b); |
| 476 } | 483 } |
| 477 | 484 |
| 478 } // namespace url_util | 485 } // namespace url_util |
| OLD | NEW |