Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* Based on nsURLParsers.cc from Mozilla | 1 /* Based on nsURLParsers.cc from Mozilla |
| 2 * ------------------------------------- | 2 * ------------------------------------- |
| 3 * The contents of this file are subject to the Mozilla Public License Version | 3 * The contents of this file are subject to the Mozilla Public License Version |
| 4 * 1.1 (the "License"); you may not use this file except in compliance with | 4 * 1.1 (the "License"); you may not use this file except in compliance with |
| 5 * the License. You may obtain a copy of the License at | 5 * the License. You may obtain a copy of the License at |
| 6 * http://www.mozilla.org/MPL/ | 6 * http://www.mozilla.org/MPL/ |
| 7 * | 7 * |
| 8 * Software distributed under the License is distributed on an "AS IS" basis, | 8 * Software distributed under the License is distributed on an "AS IS" basis, |
| 9 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | 9 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 10 * for the specific language governing rights and limitations under the | 10 * for the specific language governing rights and limitations under the |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 // Handle empty paths: they have no file names. | 618 // Handle empty paths: they have no file names. |
| 619 if (!path.is_nonempty()) { | 619 if (!path.is_nonempty()) { |
| 620 file_name->reset(); | 620 file_name->reset(); |
| 621 return; | 621 return; |
| 622 } | 622 } |
| 623 | 623 |
| 624 // Search backwards for a parameter, which is a normally unused field in a | 624 // Search backwards for a parameter, which is a normally unused field in a |
| 625 // URL delimited by a semicolon. We parse the parameter as part of the | 625 // URL delimited by a semicolon. We parse the parameter as part of the |
| 626 // path, but here, we don't want to count it. The last semicolon is the | 626 // path, but here, we don't want to count it. The last semicolon is the |
| 627 // parameter. The path should start with a slash, so we don't need to check | 627 // parameter. The path should start with a slash, so we don't need to check |
| 628 // the first one. | 628 // the first one. |
|
asanka
2014/09/17 20:56:25
Update the comment?
I'd suggest adding a referenc
brettw
2014/10/14 18:28:55
Yes, this needs updating. The whole thing should b
| |
| 629 int file_end = path.end(); | 629 int file_end = path.end(); |
| 630 for (int i = path.end() - 1; i > path.begin; i--) { | 630 for (int i = path.end() - 1; i >= path.begin; i--) { |
| 631 if (spec[i] == ';') { | 631 if (spec[i] == ';') { |
| 632 file_end = i; | 632 file_end = i; |
| 633 break; | 633 } else if (IsURLSlash(spec[i])) { |
| 634 } | |
| 635 } | |
| 636 | |
| 637 // Now search backwards from the filename end to the previous slash | |
| 638 // to find the beginning of the filename. | |
| 639 for (int i = file_end - 1; i >= path.begin; i--) { | |
| 640 if (IsURLSlash(spec[i])) { | |
| 641 // File name is everything following this character to the end | 634 // File name is everything following this character to the end |
| 642 *file_name = MakeRange(i + 1, file_end); | 635 *file_name = MakeRange(i + 1, file_end); |
| 643 return; | 636 return; |
| 644 } | 637 } |
| 645 } | 638 } |
| 646 | 639 |
| 647 // No slash found, this means the input was degenerate (generally paths | 640 // No slash found, this means the input was degenerate (generally paths |
| 648 // will start with a slash). Let's call everything the file name. | 641 // will start with a slash). Let's call everything the file name. |
| 649 *file_name = MakeRange(path.begin, file_end); | 642 *file_name = MakeRange(path.begin, file_end); |
| 650 return; | 643 return; |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 935 } | 928 } |
| 936 | 929 |
| 937 void ParseAfterScheme(const base::char16* spec, | 930 void ParseAfterScheme(const base::char16* spec, |
| 938 int spec_len, | 931 int spec_len, |
| 939 int after_scheme, | 932 int after_scheme, |
| 940 Parsed* parsed) { | 933 Parsed* parsed) { |
| 941 DoParseAfterScheme(spec, spec_len, after_scheme, parsed); | 934 DoParseAfterScheme(spec, spec_len, after_scheme, parsed); |
| 942 } | 935 } |
| 943 | 936 |
| 944 } // namespace url | 937 } // namespace url |
| OLD | NEW |