diff options
author | finnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-07 18:10:33 +0000 |
---|---|---|
committer | finnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-07 18:10:33 +0000 |
commit | 3188829de6b1aa77dbac30c78ee0bb5a16f31666 (patch) | |
tree | 807aa40a7066bbdf29aefc1d50e03f26da937172 /chrome | |
parent | 7f807d536a7a72a46fd05bbc8b9d83eac0c1d4e3 (diff) | |
download | chromium_src-3188829de6b1aa77dbac30c78ee0bb5a16f31666.zip chromium_src-3188829de6b1aa77dbac30c78ee0bb5a16f31666.tar.gz chromium_src-3188829de6b1aa77dbac30c78ee0bb5a16f31666.tar.bz2 |
Checking in patch for Brian Duff, reviewed by pkasting (http://codereview.chromium.org/16511)
If the URL text has no scheme, and starts with ftp., then
default the scheme to ftp: instead of http:. Fixes issue 565.
BUG=565
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/url_fixer_upper.cc | 15 | ||||
-rw-r--r-- | chrome/browser/url_fixer_upper_unittest.cc | 6 |
2 files changed, 11 insertions, 10 deletions
diff --git a/chrome/browser/url_fixer_upper.cc b/chrome/browser/url_fixer_upper.cc index a62694d..8ad4fbb 100644 --- a/chrome/browser/url_fixer_upper.cc +++ b/chrome/browser/url_fixer_upper.cc @@ -287,16 +287,11 @@ wstring URLFixerUpper::SegmentURL(const wstring& text, parts->scheme.reset(); } - // Check to see if we've found a scheme we liked. - int scheme_end; - if (parts->scheme.is_valid()) { - // Remember the end of the scheme. - scheme_end = parts->scheme.end(); - } else { - // Having been unable to extract a scheme, we default to HTTP. - scheme.assign(L"http"); - scheme_end = 0; - } + // When we couldn't find a scheme in the input, we need to pick one. Normally + // we choose http, but if the URL starts with "ftp.", we match other browsers + // and choose ftp. + if (!parts->scheme.is_valid()) + scheme.assign(StartsWith(text, L"ftp.", false) ? L"ftp" : L"http"); // Cannonicalize the scheme. StringToLowerASCII(&scheme); diff --git a/chrome/browser/url_fixer_upper_unittest.cc b/chrome/browser/url_fixer_upper_unittest.cc index e793505..111874b 100644 --- a/chrome/browser/url_fixer_upper_unittest.cc +++ b/chrome/browser/url_fixer_upper_unittest.cc @@ -173,6 +173,12 @@ struct fixup_case { // a clean way to guess this isn't the new-and-exciting "user" scheme. {L"user:passwd@www.google.com:8080/", L"", L"user:passwd@www.google.com:8080/"}, //{L"file:///c:/foo/bar%20baz.txt", L"", L"file:///C:/foo/bar%20baz.txt"}, + {L"ftp.google.com", L"", L"ftp://ftp.google.com/"}, + {L" ftp.google.com", L"", L"ftp://ftp.google.com/"}, + {L"FTP.GooGle.com", L"", L"ftp://FTP.GooGle.com/"}, + {L"ftpblah.google.com", L"", L"http://ftpblah.google.com/"}, + {L"ftp", L"", L"http://ftp/"}, + {L"google.ftp.com", L"", L"http://google.ftp.com/"}, }; TEST(URLFixerUpperTest, FixupURL) { |