summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-07 01:34:53 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-07 01:34:53 +0000
commitce85f60cd9d399109dab39fe5a9613879ab9a8f7 (patch)
tree0e9e0072d2e5eadfeec08eef0f06a43c56dc1751 /chrome
parentd90684d0cf0aa16389c9202153c97d373829b7f3 (diff)
downloadchromium_src-ce85f60cd9d399109dab39fe5a9613879ab9a8f7.zip
chromium_src-ce85f60cd9d399109dab39fe5a9613879ab9a8f7.tar.gz
chromium_src-ce85f60cd9d399109dab39fe5a9613879ab9a8f7.tar.bz2
Fix various problems with inline autocomplete and URLs that change length during fixup:
* URLs with http auth info, which gets stripped * URLs with IDN hosts * URLs with escaped values that get unescaped In cases like these, we'd inline autocomplete from the wrong locations, highlight the wrong portions of the URL as matches, and sometimes DCHECK() in debug mode. The fix is to track how fixup affects the offsets into the URL we care about. Plumbing this required an enormous number of additions :( There is also a fix here to the URL Fixer Upper, which was obviously modified at some point in the past to use the Parsed components, but without updating the comments or some of the functionality to match. Since this isn't supposed to "fix up" things that aren't simple typos, I removed some code to "fix" bogus ports, which was causing bizarre effects when typing HTTP auth URLs ("http://foo:bar" would be fixed to "http://foo" and then matched for inline autocompletion, which was clearly wrong). This is tested incidentally by one of the new History URL Provider tests (which is how I discovered it). BUG=4010 TEST=Covered by unittests Review URL: http://codereview.chromium.org/372017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31352 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc7
-rw-r--r--chrome/browser/autocomplete/autocomplete.h8
-rw-r--r--chrome/browser/autocomplete/history_url_provider.cc59
-rw-r--r--chrome/browser/autocomplete/history_url_provider.h20
-rw-r--r--chrome/browser/autocomplete/history_url_provider_unittest.cc29
-rw-r--r--chrome/browser/bookmarks/bookmark_table_model.cc7
-rw-r--r--chrome/browser/bookmarks/bookmark_utils.cc2
-rw-r--r--chrome/browser/gtk/options/exceptions_page_gtk.cc3
-rw-r--r--chrome/browser/gtk/options/passwords_page_gtk.cc3
-rw-r--r--chrome/browser/gtk/options/url_picker_dialog_gtk.cc5
-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
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc4
-rw-r--r--chrome/browser/toolbar_model.cc5
-rw-r--r--chrome/browser/views/bookmark_editor_view.cc7
-rw-r--r--chrome/browser/views/url_picker.cc7
17 files changed, 118 insertions, 95 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index f9223b4..1b0340d2 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -438,10 +438,6 @@ void AutocompleteMatch::ClassifyLocationInString(
size_t overall_length,
int style,
ACMatchClassifications* classification) {
- // Classifying an empty match makes no sense and will lead to validation
- // errors later.
- DCHECK(match_length > 0);
-
classification->clear();
// Don't classify anything about an empty string
@@ -459,6 +455,9 @@ void AutocompleteMatch::ClassifyLocationInString(
// No match, above classification will suffice for whole string.
return;
}
+ // Classifying an empty match makes no sense and will lead to validation
+ // errors later.
+ DCHECK(match_length > 0);
classification->push_back(ACMatchClassification(match_location,
(style | ACMatchClassification::MATCH) & ~ACMatchClassification::DIM));
diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h
index 0193b8c..f5d9ac0 100644
--- a/chrome/browser/autocomplete/autocomplete.h
+++ b/chrome/browser/autocomplete/autocomplete.h
@@ -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.
@@ -548,9 +548,9 @@ class AutocompleteProvider
// profile's bookmark bar model.
void UpdateStarredStateOfMatches();
- // A convenience function to call gfx::GetCleanStringFromUrl() with the
- // current set of "Accept Languages" when check_accept_lang is true.
- // Otherwise, it's called with an empty list.
+ // A convenience function to call net::FormatUrl() with the current set of
+ // "Accept Languages" when check_accept_lang is true. Otherwise, it's called
+ // with an empty list.
std::wstring StringForURLDisplay(const GURL& url,
bool check_accept_lang) const;
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index b44b6e7..a1d971a 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -68,9 +68,8 @@ void HistoryURLProvider::DeleteMatch(const AutocompleteMatch& match) {
DCHECK(done_);
// Delete the match from the history DB.
- HistoryService* history_service =
- profile_ ? profile_->GetHistoryService(Profile::EXPLICIT_ACCESS) :
- history_service_;
+ HistoryService* const history_service =
+ profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
GURL selected_url(match.destination_url);
if (!history_service || !selected_url.is_valid()) {
NOTREACHED() << "Can't delete requested URL";
@@ -628,16 +627,17 @@ void HistoryURLProvider::RunAutocompletePasses(
matches_.push_back(SuggestExactInput(input, trim_http));
// We'll need the history service to run both passes, so try to obtain it.
- HistoryService* const history_service = profile_ ?
- profile_->GetHistoryService(Profile::EXPLICIT_ACCESS) : history_service_;
+ HistoryService* const history_service =
+ profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
if (!history_service)
return;
// Create the data structure for the autocomplete passes. We'll save this off
// onto the |params_| member for later deletion below if we need to run pass
// 2.
- const std::wstring& languages = profile_ ?
- profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : std::wstring();
+ std::wstring languages(languages_);
+ if (languages.empty() && profile_)
+ languages = profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
scoped_ptr<HistoryURLProviderParams> params(
new HistoryURLProviderParams(input, trim_http, languages));
@@ -826,28 +826,47 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch(
!!info.visit_count(), AutocompleteMatch::HISTORY_URL);
match.destination_url = info.url();
DCHECK(match.destination_url.is_valid());
+ size_t inline_autocomplete_offset =
+ history_match.input_location + params->input.text().length();
match.fill_into_edit = net::FormatUrl(info.url(),
- match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages);
- if (!params->input.prevent_inline_autocomplete()) {
- match.inline_autocomplete_offset =
- history_match.input_location + params->input.text().length();
- }
+ match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages, true,
+ UnescapeRule::SPACES, NULL, NULL, &inline_autocomplete_offset);
size_t offset = 0;
if (params->trim_http && !history_match.match_in_scheme) {
offset = TrimHttpPrefix(&match.fill_into_edit);
- if (match.inline_autocomplete_offset != std::wstring::npos) {
- DCHECK(match.inline_autocomplete_offset >= offset);
- match.inline_autocomplete_offset -= offset;
+ if (inline_autocomplete_offset != std::wstring::npos) {
+ DCHECK(inline_autocomplete_offset >= offset);
+ inline_autocomplete_offset -= offset;
}
}
+ if (!params->input.prevent_inline_autocomplete())
+ match.inline_autocomplete_offset = inline_autocomplete_offset;
DCHECK((match.inline_autocomplete_offset == std::wstring::npos) ||
(match.inline_autocomplete_offset <= match.fill_into_edit.length()));
- match.contents = match.fill_into_edit;
- AutocompleteMatch::ClassifyLocationInString(
- history_match.input_location - offset, params->input.text().length(),
- match.contents.length(), ACMatchClassification::URL,
- &match.contents_class);
+ size_t match_start = history_match.input_location;
+ match.contents = net::FormatUrl(info.url(),
+ match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages, true,
+ UnescapeRule::SPACES, NULL, NULL, &match_start);
+ if (offset) {
+ TrimHttpPrefix(&match.contents);
+ if (match_start != std::wstring::npos) {
+ DCHECK(match_start >= offset);
+ match_start -= offset;
+ }
+ }
+ if ((match_start != std::wstring::npos) &&
+ (inline_autocomplete_offset != std::wstring::npos) &&
+ (inline_autocomplete_offset != match_start)) {
+ DCHECK(inline_autocomplete_offset > match_start);
+ AutocompleteMatch::ClassifyLocationInString(match_start,
+ inline_autocomplete_offset - match_start, match.contents.length(),
+ ACMatchClassification::URL, &match.contents_class);
+ } else {
+ AutocompleteMatch::ClassifyLocationInString(std::wstring::npos, 0,
+ match.contents.length(), ACMatchClassification::URL,
+ &match.contents_class);
+ }
match.description = info.title();
AutocompleteMatch::ClassifyMatchInString(params->input.text(), info.title(),
ACMatchClassification::NONE,
diff --git a/chrome/browser/autocomplete/history_url_provider.h b/chrome/browser/autocomplete/history_url_provider.h
index 50f6ba7..152a938 100644
--- a/chrome/browser/autocomplete/history_url_provider.h
+++ b/chrome/browser/autocomplete/history_url_provider.h
@@ -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.
@@ -135,18 +135,18 @@ class HistoryURLProvider : public AutocompleteProvider {
public:
HistoryURLProvider(ACProviderListener* listener, Profile* profile)
: AutocompleteProvider(listener, profile, "HistoryURL"),
- history_service_(NULL),
prefixes_(GetPrefixes()),
params_(NULL) {
}
#ifdef UNIT_TEST
HistoryURLProvider(ACProviderListener* listener,
- HistoryService* history_service)
- : AutocompleteProvider(listener, NULL, "History"),
- history_service_(history_service),
+ Profile* profile,
+ const std::wstring& languages)
+ : AutocompleteProvider(listener, profile, "History"),
prefixes_(GetPrefixes()),
- params_(NULL) {
+ params_(NULL),
+ languages_(languages) {
}
#endif
// no destructor (see note above)
@@ -379,10 +379,6 @@ class HistoryURLProvider : public AutocompleteProvider {
MatchType match_type,
size_t match_number);
- // This is only non-null for testing, otherwise the HistoryService from the
- // Profile is used.
- HistoryService* history_service_;
-
// Prefixes to try appending to user input when looking for a match.
const Prefixes prefixes_;
@@ -391,6 +387,10 @@ class HistoryURLProvider : public AutocompleteProvider {
// parameter itself is freed once it's no longer needed. The only reason we
// keep this member is so we can set the cancel bit on it.
HistoryURLProviderParams* params_;
+
+ // Only used by unittests; if non-empty, overrides accept-languages in the
+ // profile's pref system.
+ std::wstring languages_;
};
#endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_
diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc
index 408526a..45e1426 100644
--- a/chrome/browser/autocomplete/history_url_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc
@@ -83,6 +83,11 @@ static TestURLInfo test_db[] = {
{"http://go/", L"Intranet URL", 1, 1},
{"http://gooey/", L"Intranet URL 2", 5, 5},
+ // URLs for testing offset adjustment
+ {"http://www.\xEA\xB5\x90\xEC\x9C\xA1.kr/", L"Korean", 2, 2},
+ {"http://spaces.com/path%20with%20spaces/foo.html", L"Spaces", 2, 2},
+ {"http://ms/c++%20style%20guide", L"Style guide", 2, 2},
+ {"http://foo:bar@baz.com/", L"HTTP auth", 2, 2},
};
class HistoryURLProviderTest : public testing::Test,
@@ -116,6 +121,8 @@ class HistoryURLProviderTest : public testing::Test,
const std::string* expected_urls,
size_t num_results);
+ void RunAdjustOffsetTest(const std::wstring text, size_t expected_offset);
+
MessageLoopForUI message_loop_;
ChromeThread ui_thread_;
ChromeThread file_thread_;
@@ -144,7 +151,7 @@ void HistoryURLProviderTest::SetUpImpl(bool no_db) {
profile_->CreateHistoryService(true, no_db);
history_service_ = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
- autocomplete_ = new HistoryURLProvider(this, profile_.get());
+ autocomplete_ = new HistoryURLProvider(this, profile_.get(), L"en-US,en,ko");
FillData();
}
@@ -189,6 +196,18 @@ void HistoryURLProviderTest::RunTest(const std::wstring text,
EXPECT_EQ(expected_urls[i], matches_[i].destination_url.spec());
}
+void HistoryURLProviderTest::RunAdjustOffsetTest(const std::wstring text,
+ size_t expected_offset) {
+ AutocompleteInput input(text, std::wstring(), false, false, false);
+ autocomplete_->Start(input, false);
+ if (!autocomplete_->done())
+ MessageLoop::current()->Run();
+
+ matches_ = autocomplete_->matches();
+ ASSERT_GE(matches_.size(), 1U) << "Input text: " << text;
+ EXPECT_EQ(expected_offset, matches_[0].inline_autocomplete_offset);
+}
+
TEST_F(HistoryURLProviderTest, PromoteShorterURLs) {
// Test that hosts get synthesized below popular pages.
const std::string expected_nonsynth[] = {
@@ -382,6 +401,14 @@ TEST_F(HistoryURLProviderTest, Fixup) {
RunTest(L"17173", std::wstring(), false, fixup_5, arraysize(fixup_5));
}
+TEST_F(HistoryURLProviderTest, AdjustOffset) {
+ RunAdjustOffsetTest(L"http://www.\uAD50\uC721", 13);
+ RunAdjustOffsetTest(L"http://spaces.com/path%20with%20spa", 31);
+ RunAdjustOffsetTest(L"http://ms/c++ s", 15);
+ RunAdjustOffsetTest(L"http://foo:ba", std::wstring::npos);
+ RunAdjustOffsetTest(L"http://foo:bar@ba", 9);
+}
+
TEST_F(HistoryURLProviderTestNoDB, NavigateWithoutDB) {
// Ensure that we will still produce matches for navigation when there is no
// database.
diff --git a/chrome/browser/bookmarks/bookmark_table_model.cc b/chrome/browser/bookmarks/bookmark_table_model.cc
index 142090c..9b4fd82 100644
--- a/chrome/browser/bookmarks/bookmark_table_model.cc
+++ b/chrome/browser/bookmarks/bookmark_table_model.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.
@@ -324,9 +324,8 @@ std::wstring BookmarkTableModel::GetText(int row, int column_id) {
std::wstring languages = model_ && model_->profile()
? model_->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)
: std::wstring();
- std::wstring url_text =
- net::FormatUrl(node->GetURL(), languages, false, UnescapeRule::SPACES,
- NULL, NULL);
+ std::wstring url_text = net::FormatUrl(node->GetURL(), languages, false,
+ UnescapeRule::SPACES, NULL, NULL, NULL);
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
l10n_util::WrapStringWithLTRFormatting(&url_text);
return url_text;
diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc
index 54ea21cb..e62a30a 100644
--- a/chrome/browser/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/bookmarks/bookmark_utils.cc
@@ -187,7 +187,7 @@ bool DoesBookmarkContainWords(const BookmarkNode* node,
l10n_util::ToLower(node->GetTitle()), words) ||
DoesBookmarkTextContainWords(UTF8ToWide(node->GetURL().spec()), words) ||
DoesBookmarkTextContainWords(net::FormatUrl(
- node->GetURL(), languages, false, true, NULL, NULL), words);
+ node->GetURL(), languages, false, true, NULL, NULL, NULL), words);
}
} // namespace
diff --git a/chrome/browser/gtk/options/exceptions_page_gtk.cc b/chrome/browser/gtk/options/exceptions_page_gtk.cc
index 164a821..10a8f2d 100644
--- a/chrome/browser/gtk/options/exceptions_page_gtk.cc
+++ b/chrome/browser/gtk/options/exceptions_page_gtk.cc
@@ -113,8 +113,7 @@ void ExceptionsPageGtk::SetExceptionList(
for (size_t i = 0; i < result.size(); ++i) {
exception_list_[i] = *result[i];
std::wstring formatted = net::FormatUrl(result[i]->origin, languages,
- false, UnescapeRule::NONE,
- NULL, NULL);
+ false, UnescapeRule::NONE, NULL, NULL, NULL);
std::string site = WideToUTF8(formatted);
GtkTreeIter iter;
gtk_list_store_insert_with_values(exception_list_store_, &iter, (gint) i,
diff --git a/chrome/browser/gtk/options/passwords_page_gtk.cc b/chrome/browser/gtk/options/passwords_page_gtk.cc
index b2f6345..f4a2197 100644
--- a/chrome/browser/gtk/options/passwords_page_gtk.cc
+++ b/chrome/browser/gtk/options/passwords_page_gtk.cc
@@ -156,8 +156,7 @@ void PasswordsPageGtk::SetPasswordList(
for (size_t i = 0; i < result.size(); ++i) {
password_list_[i] = *result[i];
std::wstring formatted = net::FormatUrl(result[i]->origin, languages,
- false, UnescapeRule::NONE,
- NULL, NULL);
+ false, UnescapeRule::NONE, NULL, NULL, NULL);
std::string site = WideToUTF8(formatted);
std::string user = UTF16ToUTF8(result[i]->username_value);
GtkTreeIter iter;
diff --git a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc
index 6c4e38f..e646552 100644
--- a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc
+++ b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc
@@ -196,9 +196,8 @@ std::string UrlPickerDialogGtk::GetURLForPath(GtkTreePath* path) const {
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
// Because the url_field_ is user-editable, we set the URL with
// username:password and escaped path and query.
- std::wstring formatted = net::FormatUrl(
- url_table_model_->GetURL(row), languages,
- false, UnescapeRule::NONE, NULL, NULL);
+ std::wstring formatted = net::FormatUrl(url_table_model_->GetURL(row),
+ languages, false, UnescapeRule::NONE, NULL, NULL, NULL);
return WideToUTF8(formatted);
}
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"},
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 3a34459..4e45553 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -2517,9 +2517,9 @@ void TabContents::LoadStateChanged(const GURL& url,
upload_size_ = upload_size;
std::wstring languages =
profile()->GetPrefs()->GetString(prefs::kAcceptLanguages);
- load_state_host_.clear();
std::string host = url.host();
- net::IDNToUnicode(host.c_str(), host.size(), languages, &load_state_host_);
+ load_state_host_ =
+ net::IDNToUnicode(host.c_str(), host.size(), languages, NULL);
if (load_state_ == net::LOAD_STATE_READING_RESPONSE)
SetNotWaitingForResponse();
if (is_loading())
diff --git a/chrome/browser/toolbar_model.cc b/chrome/browser/toolbar_model.cc
index 1169c42..42977f6 100644
--- a/chrome/browser/toolbar_model.cc
+++ b/chrome/browser/toolbar_model.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.
@@ -41,7 +41,8 @@ std::wstring ToolbarModel::GetText() {
url = entry->virtual_url();
}
}
- return net::FormatUrl(url, languages, true, UnescapeRule::NORMAL, NULL, NULL);
+ return net::FormatUrl(url, languages, true, UnescapeRule::NORMAL, NULL, NULL,
+ NULL);
}
ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() {
diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc
index 5443f81..f40e25f 100644
--- a/chrome/browser/views/bookmark_editor_view.cc
+++ b/chrome/browser/views/bookmark_editor_view.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.
@@ -278,9 +278,8 @@ void BookmarkEditorView::Init() {
: std::wstring();
// The following URL is user-editable. We specify omit_username_password=
// false and unescape=false to show the original URL except IDN.
- url_text =
- net::FormatUrl(details_.existing_node->GetURL(), languages, false,
- UnescapeRule::NONE, NULL, NULL);
+ url_text = net::FormatUrl(details_.existing_node->GetURL(), languages,
+ false, UnescapeRule::NONE, NULL, NULL, NULL);
}
url_tf_.SetText(url_text);
url_tf_.SetController(this);
diff --git a/chrome/browser/views/url_picker.cc b/chrome/browser/views/url_picker.cc
index 5232676..0133dbd 100644
--- a/chrome/browser/views/url_picker.cc
+++ b/chrome/browser/views/url_picker.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.
@@ -293,9 +293,8 @@ void UrlPicker::OnSelectionChanged() {
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
// Because the url_field_ is user-editable, we set the URL with
// username:password and escaped path and query.
- std::wstring formatted = net::FormatUrl(
- url_table_model_->GetURL(selection), languages,
- false, UnescapeRule::NONE, NULL, NULL);
+ std::wstring formatted = net::FormatUrl(url_table_model_->GetURL(selection),
+ languages, false, UnescapeRule::NONE, NULL, NULL, NULL);
url_field_->SetText(formatted);
if (title_field_)
title_field_->SetText(url_table_model_->GetTitle(selection));