| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // character in the output on failure for us). | 265 // character in the output on failure for us). |
| 266 unsigned code_point; | 266 unsigned code_point; |
| 267 ReadUTFChar(spec, &i, end, &code_point); | 267 ReadUTFChar(spec, &i, end, &code_point); |
| 268 AppendUTF8Value(code_point, output); | 268 AppendUTF8Value(code_point, output); |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 | 271 |
| 272 out_ref->len = output->length() - out_ref->begin; | 272 out_ref->len = output->length() - out_ref->begin; |
| 273 } | 273 } |
| 274 | 274 |
| 275 template <typename CHAR, typename UCHAR> |
| 276 bool DoCanonicalizeNonStandardURL(const URLComponentSource<CHAR>& source, |
| 277 const Parsed& parsed, |
| 278 CharsetConverter* query_converter, |
| 279 CanonOutput* output, |
| 280 Parsed* new_parsed) { |
| 281 // Scheme: this will append the colon. |
| 282 bool success = CanonicalizeScheme(source.scheme, parsed.scheme, output, |
| 283 &new_parsed->scheme); |
| 284 |
| 285 new_parsed->username.reset(); |
| 286 new_parsed->password.reset(); |
| 287 new_parsed->host.reset(); |
| 288 new_parsed->port.reset(); |
| 289 new_parsed->path.reset(); |
| 290 new_parsed->query.reset(); |
| 291 new_parsed->ref.reset(); |
| 292 |
| 293 return success; |
| 294 } |
| 295 |
| 275 } // namespace | 296 } // namespace |
| 276 | 297 |
| 277 const char* RemoveURLWhitespace(const char* input, int input_len, | 298 const char* RemoveURLWhitespace(const char* input, int input_len, |
| 278 CanonOutputT<char>* buffer, | 299 CanonOutputT<char>* buffer, |
| 279 int* output_len) { | 300 int* output_len) { |
| 280 return DoRemoveURLWhitespace(input, input_len, buffer, output_len); | 301 return DoRemoveURLWhitespace(input, input_len, buffer, output_len); |
| 281 } | 302 } |
| 282 | 303 |
| 283 const base::char16* RemoveURLWhitespace(const base::char16* input, | 304 const base::char16* RemoveURLWhitespace(const base::char16* input, |
| 284 int input_len, | 305 int input_len, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 DoCanonicalizeRef<char, unsigned char>(spec, ref, output, out_ref); | 378 DoCanonicalizeRef<char, unsigned char>(spec, ref, output, out_ref); |
| 358 } | 379 } |
| 359 | 380 |
| 360 void CanonicalizeRef(const base::char16* spec, | 381 void CanonicalizeRef(const base::char16* spec, |
| 361 const Component& ref, | 382 const Component& ref, |
| 362 CanonOutput* output, | 383 CanonOutput* output, |
| 363 Component* out_ref) { | 384 Component* out_ref) { |
| 364 DoCanonicalizeRef<base::char16, base::char16>(spec, ref, output, out_ref); | 385 DoCanonicalizeRef<base::char16, base::char16>(spec, ref, output, out_ref); |
| 365 } | 386 } |
| 366 | 387 |
| 388 bool CanonicalizeNonStandardURL(const char* spec, |
| 389 int spec_len, |
| 390 const Parsed& parsed, |
| 391 CharsetConverter* query_converter, |
| 392 CanonOutput* output, |
| 393 Parsed* new_parsed) { |
| 394 return DoCanonicalizeNonStandardURL<char, unsigned char>( |
| 395 URLComponentSource<char>(spec), parsed, query_converter, output, |
| 396 new_parsed); |
| 397 } |
| 398 |
| 399 bool CanonicalizeNonStandardURL(const base::char16* spec, |
| 400 int spec_len, |
| 401 const Parsed& parsed, |
| 402 CharsetConverter* query_converter, |
| 403 CanonOutput* output, |
| 404 Parsed* new_parsed) { |
| 405 return DoCanonicalizeNonStandardURL<base::char16, base::char16>( |
| 406 URLComponentSource<base::char16>(spec), parsed, query_converter, output, |
| 407 new_parsed); |
| 408 } |
| 409 |
| 367 } // namespace url | 410 } // namespace url |
| OLD | NEW |