Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: net/base/net_util.cc

Issue 1574034: Changes FormatURL to not strip http if the host starts with ftp or https[!a-z]. This... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/net_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_util.cc
===================================================================
--- net/base/net_util.cc (revision 44745)
+++ net/base/net_util.cc (working copy)
@@ -1392,6 +1392,8 @@
url_parse::Parsed parsed_temp;
if (!new_parsed)
new_parsed = &parsed_temp;
+ else
+ *new_parsed = url_parse::Parsed();
size_t offset_temp = std::wstring::npos;
if (!offset_for_adjustment)
offset_for_adjustment = &offset_temp;
@@ -1432,9 +1434,20 @@
std::back_inserter(url_string));
const wchar_t* const kHTTP = L"http://";
+ const char* const kFTP = "ftp.";
const size_t kHTTPSize = std::wstring(kHTTP).size();
- bool omit_http = ((format_types & kFormatUrlOmitHTTP) != 0 &&
- url_string == kHTTP);
+ // The omnibox treats ftp.foo.com as ftp://foo.com. This means that if we
+ // trimmed http off a string that starts with http://ftp and the user tried to
+ // reload the page the user would end up with a scheme of ftp://. For example,
+ // 'http://ftp.foo.com' -> 'ftp.foo.com' -> 'ftp://foo.com'. For this reason
+ // don't strip http off url's whose scheme is http and the host starts with
+ // 'ftp.'.
+ bool omit_http =
+ ((format_types & kFormatUrlOmitHTTP) != 0 &&
+ url_string == kHTTP && (!parsed.host.is_valid() ||
+ (parsed.host.is_nonempty() &&
+ spec.compare(parsed.host.begin,
+ std::string(kFTP).size(), kFTP))));
new_parsed->scheme = parsed.scheme;
« no previous file with comments | « no previous file | net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698