Chromium Code Reviews| Index: url/third_party/mozilla/url_parse.cc |
| diff --git a/url/third_party/mozilla/url_parse.cc b/url/third_party/mozilla/url_parse.cc |
| index fbc8a9baf7a2fc97ef70a71cf58083d3c12e36ec..4b737454a779c9a38d7719f3f9ed4eb5a08a6e97 100644 |
| --- a/url/third_party/mozilla/url_parse.cc |
| +++ b/url/third_party/mozilla/url_parse.cc |
| @@ -455,19 +455,22 @@ void DoParseFileSystemURL(const CHAR* spec, int spec_len, Parsed* parsed) { |
| // Initializes a path URL which is merely a scheme followed by a path. Examples |
| // include "about:foo" and "javascript:alert('bar');" |
| template<typename CHAR> |
| -void DoParsePathURL(const CHAR* spec, int spec_len, Parsed* parsed) { |
| +void DoParsePathURL(const CHAR* spec, int spec_len, |
| + bool trim_path_end, |
| + Parsed* parsed) { |
| // Get the non-path and non-scheme parts of the URL out of the way, we never |
| // use them. |
| parsed->username.reset(); |
| parsed->password.reset(); |
| parsed->host.reset(); |
| parsed->port.reset(); |
| + parsed->path.reset(); |
| parsed->query.reset(); |
| parsed->ref.reset(); |
| // Strip leading & trailing spaces and control characters. |
| int begin = 0; |
| - TrimURL(spec, &begin, &spec_len); |
| + TrimURL(spec, &begin, &spec_len, trim_path_end); |
| // Handle empty specs or ones that contain only whitespace or control chars. |
| if (begin == spec_len) { |
| @@ -481,19 +484,20 @@ void DoParsePathURL(const CHAR* spec, int spec_len, Parsed* parsed) { |
| if (ExtractScheme(&spec[begin], spec_len - begin, &parsed->scheme)) { |
| // Offset the results since we gave ExtractScheme a substring. |
| parsed->scheme.begin += begin; |
| - |
| - // For compatability with the standard URL parser, we treat no path as |
| - // -1, rather than having a length of 0 (we normally wouldn't care so |
| - // much for these non-standard URLs). |
| - if (parsed->scheme.end() == spec_len - 1) |
| - parsed->path.reset(); |
| - else |
| - parsed->path = MakeRange(parsed->scheme.end() + 1, spec_len); |
| + begin = parsed->scheme.end() + 1; |
|
brettw
2013/11/20 00:03:51
I'd rather introduce a new after_scheme variable h
joth
2013/11/21 00:08:45
Done.
|
| } else { |
| - // No scheme found, just path. |
| parsed->scheme.reset(); |
| - parsed->path = MakeRange(begin, spec_len); |
| } |
| + |
| + if (begin == spec_len) |
| + return; |
| + DCHECK_LT(begin, spec_len); |
| + |
| + ParsePath(spec, |
| + MakeRange(begin, spec_len), |
| + &parsed->path, |
| + &parsed->query, |
| + &parsed->ref); |
| } |
| template<typename CHAR> |
| @@ -875,12 +879,18 @@ void ParseStandardURL(const base::char16* url, int url_len, Parsed* parsed) { |
| DoParseStandardURL(url, url_len, parsed); |
| } |
| -void ParsePathURL(const char* url, int url_len, Parsed* parsed) { |
| - DoParsePathURL(url, url_len, parsed); |
| +void ParsePathURL(const char* url, |
| + int url_len, |
| + bool trim_path_end, |
| + Parsed* parsed) { |
| + DoParsePathURL(url, url_len, trim_path_end, parsed); |
| } |
| -void ParsePathURL(const base::char16* url, int url_len, Parsed* parsed) { |
| - DoParsePathURL(url, url_len, parsed); |
| +void ParsePathURL(const base::char16* url, |
| + int url_len, |
| + bool trim_path_end, |
| + Parsed* parsed) { |
| + DoParsePathURL(url, url_len, trim_path_end, parsed); |
| } |
| void ParseFileSystemURL(const char* url, int url_len, Parsed* parsed) { |