| 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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 host_info->out_host.begin = output->length(); | 633 host_info->out_host.begin = output->length(); |
| 634 output->push_back('['); | 634 output->push_back('['); |
| 635 | 635 |
| 636 // We will now output the address according to the rules in: | 636 // We will now output the address according to the rules in: |
| 637 // http://tools.ietf.org/html/draft-kawamura-ipv6-text-representation-01#secti
on-4 | 637 // http://tools.ietf.org/html/draft-kawamura-ipv6-text-representation-01#secti
on-4 |
| 638 | 638 |
| 639 // Start by finding where to place the "::" contraction (if any). | 639 // Start by finding where to place the "::" contraction (if any). |
| 640 url_parse::Component contraction_range; | 640 url_parse::Component contraction_range; |
| 641 ChooseIPv6ContractionRange(address, &contraction_range); | 641 ChooseIPv6ContractionRange(address, &contraction_range); |
| 642 | 642 |
| 643 for (int i = 0; i < 16;) { | 643 for (int i = 0; i <= 14;) { |
| 644 // We check 2 bytes at a time, from bytes (0, 1) to (14, 15), inclusive. |
| 645 DCHECK(i % 2 == 0); |
| 644 if (i == contraction_range.begin && contraction_range.len > 0) { | 646 if (i == contraction_range.begin && contraction_range.len > 0) { |
| 645 // Jump over the contraction. | 647 // Jump over the contraction. |
| 646 if (i == 0) | 648 if (i == 0) |
| 647 output->push_back(':'); | 649 output->push_back(':'); |
| 648 output->push_back(':'); | 650 output->push_back(':'); |
| 649 i = contraction_range.end(); | 651 i = contraction_range.end(); |
| 650 } else { | 652 } else { |
| 651 // Consume the next 16 bits from |address|. | 653 // Consume the next 16 bits from |address|. |
| 652 int x = address[i] << 8 | address[i + 1]; | 654 int x = address[i] << 8 | address[i + 1]; |
| 653 | 655 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 CanonHostInfo* host_info) { | 706 CanonHostInfo* host_info) { |
| 705 if (DoCanonicalizeIPv4Address<char16, char16>( | 707 if (DoCanonicalizeIPv4Address<char16, char16>( |
| 706 spec, host, output, host_info)) | 708 spec, host, output, host_info)) |
| 707 return; | 709 return; |
| 708 if (DoCanonicalizeIPv6Address<char16, char16>( | 710 if (DoCanonicalizeIPv6Address<char16, char16>( |
| 709 spec, host, output, host_info)) | 711 spec, host, output, host_info)) |
| 710 return; | 712 return; |
| 711 } | 713 } |
| 712 | 714 |
| 713 } // namespace url_canon | 715 } // namespace url_canon |
| OLD | NEW |