summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/browser_url_util.cc6
-rw-r--r--chrome/browser/net/url_fixer_upper.cc35
-rw-r--r--chrome/browser/net/url_fixer_upper_unittest.cc6
3 files changed, 15 insertions, 32 deletions
diff --git a/chrome/browser/net/browser_url_util.cc b/chrome/browser/net/browser_url_util.cc
index 940d3b6..5f287795 100644
--- a/chrome/browser/net/browser_url_util.cc
+++ b/chrome/browser/net/browser_url_util.cc
@@ -21,9 +21,9 @@ void WriteURLToClipboard(const GURL& url,
// Unescaping path and query is not a good idea because other applications
// may not encode non-ASCII characters in UTF-8. See crbug.com/2820.
string16 text = url.SchemeIs(chrome::kMailToScheme) ?
- ASCIIToUTF16(url.path()) :
- WideToUTF16(net::FormatUrl(url, languages, false,
- UnescapeRule::NONE, NULL, NULL));
+ ASCIIToUTF16(url.path()) :
+ WideToUTF16(net::FormatUrl(url, languages, false, UnescapeRule::NONE,
+ NULL, NULL, NULL));
ScopedClipboardWriter scw(clipboard);
scw.WriteURL(text);
diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc
index b465268..a68bc34 100644
--- a/chrome/browser/net/url_fixer_upper.cc
+++ b/chrome/browser/net/url_fixer_upper.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -146,11 +146,10 @@ static string FixupHomedir(const string& text) {
#endif
// Tries to create a file: URL from |text| if it looks like a filename, even if
-// it doesn't resolve as a valid path or to an existing file. Returns true
-// with a (possibly invalid) file: URL in |fixed_up_url| for input beginning
-// with a drive specifier or "\\". Returns false in other cases (including
-// file: URLs: these don't look like filenames), leaving fixed_up_url
-// unchanged.
+// it doesn't resolve as a valid path or to an existing file. Returns a
+// (possibly invalid) file: URL in |fixed_up_url| for input beginning
+// with a drive specifier or "\\". Returns the unchanged input in other cases
+// (including file: URLs: these don't look like filenames).
static string FixupPath(const string& text) {
DCHECK(!text.empty());
@@ -173,7 +172,7 @@ static string FixupPath(const string& text) {
GURL file_url = net::FilePathToFileURL(FilePath(filename));
if (file_url.is_valid()) {
return WideToUTF8(net::FormatUrl(file_url, std::wstring(), true,
- UnescapeRule::NORMAL, NULL, NULL));
+ UnescapeRule::NORMAL, NULL, NULL, NULL));
}
// Invalid file URL, just return the input.
@@ -182,7 +181,6 @@ static string FixupPath(const string& text) {
// Checks |domain| to see if a valid TLD is already present. If not, appends
// |desired_tld| to the domain, and prepends "www." unless it's already present.
-// Then modifies |fixed_up_url| to reflect the changes.
static void AddDesiredTLD(const string& desired_tld,
string* domain) {
if (desired_tld.empty() || domain->empty())
@@ -268,30 +266,15 @@ static void FixupHost(const string& text,
url->append(domain);
}
-// Looks for a port number, including initial colon, at port_start. If
-// something invalid (which cannot be fixed up) is found, like ":foo" or
-// ":7:7", returns false. Otherwise, removes any extra colons
-// ("::1337" -> ":1337", ":/" -> "/") and returns true.
static void FixupPort(const string& text,
const url_parse::Component& part,
string* url) {
if (!part.is_valid())
return;
- // Look for non-digit in port and strip if found.
- string port(text, part.begin, part.len);
- for (string::iterator i = port.begin(); i != port.end();) {
- if (IsAsciiDigit(*i))
- ++i;
- else
- i = port.erase(i);
- }
-
- if (port.empty())
- return; // Nothing to append.
-
+ // We don't fix up the port at the moment.
url->append(":");
- url->append(port);
+ url->append(text, part.begin, part.len);
}
static inline void FixupPath(const string& text,
@@ -573,7 +556,7 @@ string URLFixerUpper::FixupRelativeFile(const FilePath& base_dir,
GURL file_url = net::FilePathToFileURL(full_path);
if (file_url.is_valid())
return WideToUTF8(net::FormatUrl(file_url, std::wstring(),
- true, UnescapeRule::NORMAL, NULL, NULL));
+ true, UnescapeRule::NORMAL, NULL, NULL, NULL));
// Invalid files fall through to regular processing.
}
diff --git a/chrome/browser/net/url_fixer_upper_unittest.cc b/chrome/browser/net/url_fixer_upper_unittest.cc
index d7f8b93..5028cb2 100644
--- a/chrome/browser/net/url_fixer_upper_unittest.cc
+++ b/chrome/browser/net/url_fixer_upper_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -210,8 +210,8 @@ struct fixup_case {
{" foo.com/asdf bar", "", "http://foo.com/asdf bar"},
{"..www.google.com..", "", "http://www.google.com./"},
{"http://......", "", "http://....../"},
- {"http://host.com:ninety-two/", "", "http://host.com/"},
- {"http://host.com:ninety-two?foo", "", "http://host.com/?foo"},
+ {"http://host.com:ninety-two/", "", "http://host.com:ninety-two/"},
+ {"http://host.com:ninety-two?foo", "", "http://host.com:ninety-two/?foo"},
{"google.com:123", "", "http://google.com:123/"},
{"about:", "", "about:"},
{"about:version", "", "about:version"},