| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 output->push_back('/'); | 59 output->push_back('/'); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // User info: the canonicalizer will handle the : and @. | 62 // User info: the canonicalizer will handle the : and @. |
| 63 success &= CanonicalizeUserInfo(source.username, parsed.username, | 63 success &= CanonicalizeUserInfo(source.username, parsed.username, |
| 64 source.password, parsed.password, | 64 source.password, parsed.password, |
| 65 output, | 65 output, |
| 66 &new_parsed->username, | 66 &new_parsed->username, |
| 67 &new_parsed->password); | 67 &new_parsed->password); |
| 68 | 68 |
| 69 // Host: always write if we have an authority (may be empty). | |
| 70 success &= CanonicalizeHost(source.host, parsed.host, | 69 success &= CanonicalizeHost(source.host, parsed.host, |
| 71 output, &new_parsed->host); | 70 output, &new_parsed->host); |
| 72 | 71 |
| 72 // Host must not be empty for standard URLs. |
| 73 if (!parsed.host.is_nonempty()) |
| 74 success = false; |
| 75 |
| 73 // Port: the port canonicalizer will handle the colon. | 76 // Port: the port canonicalizer will handle the colon. |
| 74 int default_port = DefaultPortForScheme( | 77 int default_port = DefaultPortForScheme( |
| 75 &output->data()[new_parsed->scheme.begin], new_parsed->scheme.len); | 78 &output->data()[new_parsed->scheme.begin], new_parsed->scheme.len); |
| 76 success &= CanonicalizePort(source.port, parsed.port, default_port, | 79 success &= CanonicalizePort(source.port, parsed.port, default_port, |
| 77 output, &new_parsed->port); | 80 output, &new_parsed->port); |
| 78 } else { | 81 } else { |
| 79 // No authority, clear the components. | 82 // No authority, clear the components. |
| 80 have_authority = false; | 83 have_authority = false; |
| 81 new_parsed->host.reset(); | 84 new_parsed->host.reset(); |
| 82 new_parsed->username.reset(); | 85 new_parsed->username.reset(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 url_parse::Parsed* new_parsed) { | 187 url_parse::Parsed* new_parsed) { |
| 185 RawCanonOutput<1024> utf8; | 188 RawCanonOutput<1024> utf8; |
| 186 URLComponentSource<char> source(base); | 189 URLComponentSource<char> source(base); |
| 187 url_parse::Parsed parsed(base_parsed); | 190 url_parse::Parsed parsed(base_parsed); |
| 188 SetupUTF16OverrideComponents(base, replacements, &utf8, &source, &parsed); | 191 SetupUTF16OverrideComponents(base, replacements, &utf8, &source, &parsed); |
| 189 return DoCanonicalizeStandardURL<char, unsigned char>( | 192 return DoCanonicalizeStandardURL<char, unsigned char>( |
| 190 source, parsed, query_converter, output, new_parsed); | 193 source, parsed, query_converter, output, new_parsed); |
| 191 } | 194 } |
| 192 | 195 |
| 193 } // namespace url_canon | 196 } // namespace url_canon |
| OLD | NEW |