From 3879bbe4318182fe38f6dc5244454665e0cf62ba Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Wed, 25 Feb 2009 23:54:01 +0000 Subject: Don't accept the url "file:///" on windows (report an error). See alternate solution here: http://codereview.chromium.org/27119 r=brettw BUG=1474 Review URL: http://codereview.chromium.org/28102 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10408 0039d316-1c4b-4281-b951-d872f2087c98 --- net/url_request/url_request_file_job.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'net/url_request') diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index baf94a2..e120aa6 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -73,8 +73,9 @@ URLRequestJob* URLRequestFileJob::Factory( URLRequest* request, const std::string& scheme) { FilePath file_path; if (net::FileURLToFilePath(request->url(), &file_path) && - file_util::EnsureEndsWithSeparator(&file_path)) - return new URLRequestFileDirJob(request, file_path); + file_util::EnsureEndsWithSeparator(&file_path) && + file_path.IsAbsolute()) + return new URLRequestFileDirJob(request, file_path); // Use a regular file request job for all non-directories (including invalid // file names). @@ -165,10 +166,14 @@ void URLRequestFileJob::DidResolve( return; int rv = net::OK; - if (!exists) { + // We use URLRequestFileJob to handle valid and invalid files as well as + // invalid directories. For a directory to be invalid, it must either not + // exist, or be "\" on Windows. (Windows resolves "\" to "C:\", thus + // reporting it as existent.) On POSIX, we don't count any existent + // directory as invalid. + if (!exists || file_info.is_directory) { rv = net::ERR_FILE_NOT_FOUND; } else { - DCHECK(!file_info.is_directory); int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC; -- cgit v1.1