diff options
author | tsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-18 20:55:09 +0000 |
---|---|---|
committer | tsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-18 20:55:09 +0000 |
commit | f80e677d270a2db1037653a8182d6a04be498dce (patch) | |
tree | 0fb67e06f3d6a201a1451d14dbcc79e5d37ad68c /url/url_parse_file.cc | |
parent | b146234bd8b01a687b5f6ddaa7c6445773b2cf89 (diff) | |
download | chromium_src-f80e677d270a2db1037653a8182d6a04be498dce.zip chromium_src-f80e677d270a2db1037653a8182d6a04be498dce.tar.gz chromium_src-f80e677d270a2db1037653a8182d6a04be498dce.tar.bz2 |
Revert 223928 "Make relative file url parsing fail where there i..."
> Make relative file url parsing fail where there is a host:port in the relative URL.
>
> BUG=285720
> R=brettw@chromium.org, jar@chromium.org
>
> Review URL: https://codereview.chromium.org/23464046
TBR=tsepez@chromium.org
Review URL: https://codereview.chromium.org/23702051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223940 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'url/url_parse_file.cc')
-rw-r--r-- | url/url_parse_file.cc | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/url/url_parse_file.cc b/url/url_parse_file.cc index a2f7ce3..a8907e7 100644 --- a/url/url_parse_file.cc +++ b/url/url_parse_file.cc @@ -110,9 +110,8 @@ void DoParseLocalFile(const CHAR* spec, } // Backend for the external functions that operates on either char type. -// Handles cases where there is a scheme, but also when handed the first -// character following the "file:" at the beginning of the spec. If so, -// this is usually a slash, but needn't be; we allow paths like "file:c:\foo". +// We are handed the character after the "file:" at the beginning of the spec. +// Usually this is a slash, but needn't be; we allow paths like "file:c:\foo". template<typename CHAR> void DoParseFileURL(const CHAR* spec, int spec_len, Parsed* parsed) { DCHECK(spec_len >= 0); @@ -131,8 +130,8 @@ void DoParseFileURL(const CHAR* spec, int spec_len, Parsed* parsed) { int begin = 0; TrimURL(spec, &begin, &spec_len); - // Find the scheme, if any. - int num_slashes = CountConsecutiveSlashes(spec, begin, spec_len); + // Find the scheme. + int num_slashes; int after_scheme; int after_slashes; #ifdef WIN32 @@ -141,6 +140,7 @@ void DoParseFileURL(const CHAR* spec, int spec_len, Parsed* parsed) { // links like "c:/foo/bar" or "//foo/bar". This is also called by the // relative URL resolver when it determines there is an absolute URL, which // may give us input like "/c:/foo". + num_slashes = CountConsecutiveSlashes(spec, begin, spec_len); after_slashes = begin + num_slashes; if (DoesBeginWindowsDriveSpec(spec, after_slashes, spec_len)) { // Windows path, don't try to extract the scheme (for example, "c:\foo"). @@ -153,12 +153,7 @@ void DoParseFileURL(const CHAR* spec, int spec_len, Parsed* parsed) { } else #endif { - // ExtractScheme doesn't understand the possibility of filenames with - // colons in them, in which case it returns the entire spec up to the - // colon as the scheme. So handle /foo.c:5 as a file but foo.c:5 as - // the foo.c: scheme. - if (!num_slashes && - ExtractScheme(&spec[begin], spec_len - begin, &parsed->scheme)) { + if (ExtractScheme(&spec[begin], spec_len - begin, &parsed->scheme)) { // Offset the results since we gave ExtractScheme a substring. parsed->scheme.begin += begin; after_scheme = parsed->scheme.end() + 1; @@ -178,6 +173,7 @@ void DoParseFileURL(const CHAR* spec, int spec_len, Parsed* parsed) { } num_slashes = CountConsecutiveSlashes(spec, after_scheme, spec_len); + after_slashes = after_scheme + num_slashes; #ifdef WIN32 // Check whether the input is a drive again. We checked above for windows |