summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 04:28:25 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 04:28:25 +0000
commita6380108bbb19f149186a5abae2a013a470a6381 (patch)
tree9857ece5c11a172456b6bfeed06ffcc98a61e059
parent0d8fa3ecb7ed0a7f6e0d9cd0a750a29bd8bed370 (diff)
downloadchromium_src-a6380108bbb19f149186a5abae2a013a470a6381.zip
chromium_src-a6380108bbb19f149186a5abae2a013a470a6381.tar.gz
chromium_src-a6380108bbb19f149186a5abae2a013a470a6381.tar.bz2
Temporary fix for omnibox crash.
BUG=9760 Review URL: http://codereview.chromium.org/63095 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13340 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete_unittest.cc6
-rw-r--r--chrome/browser/net/url_fixer_upper.cc57
-rw-r--r--chrome/browser/net/url_fixer_upper.h1
3 files changed, 60 insertions, 4 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc
index 1316eeb..eb15f2a 100644
--- a/chrome/browser/autocomplete/autocomplete_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_unittest.cc
@@ -244,6 +244,12 @@ TEST(AutocompleteTest, InputType) {
}
}
+// This tests for a regression where certain input in the omnibox caused us to
+// crash. As long as the test completes without crashing, we're fine.
+TEST(AutocompleteTest, InputCrash) {
+ AutocompleteInput input(L"\uff65@s", std::wstring(), true, false, false);
+}
+
// Test that we can properly compare matches' relevance when at least one is
// negative.
TEST(AutocompleteMatch, MoreRelevant) {
diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc
index d928c96..39ae80c 100644
--- a/chrome/browser/net/url_fixer_upper.cc
+++ b/chrome/browser/net/url_fixer_upper.cc
@@ -21,6 +21,53 @@
using namespace std;
+namespace {
+
+// TODO(estade): Remove these ugly, ugly functions. They are only used in
+// SegmentURL. A url_parse::Parsed object keeps track of a bunch of indices into
+// a url string, and these need to be updated when the URL is converted from
+// UTF8 to UTF16. Instead of this after-the-fact adjustment, we should parse it
+// in the correct string format to begin with.
+url_parse::Component UTF8ComponentToWideComponent(
+ string text_utf8,
+ const url_parse::Component& component_utf8) {
+ string before_component_string = text_utf8.substr(0, component_utf8.begin);
+ string component_string = text_utf8.substr(component_utf8.begin,
+ component_utf8.len);
+ wstring before_component_string_w = UTF8ToWide(before_component_string);
+ wstring component_string_w = UTF8ToWide(component_string);
+ url_parse::Component component_w(before_component_string_w.length(),
+ component_string_w.length());
+ return component_w;
+}
+
+void UTF8PartsToWideParts(string text_utf8, const url_parse::Parsed& parts_utf8,
+ url_parse::Parsed* parts) {
+ if (IsStringASCII(text_utf8)) {
+ *parts = parts_utf8;
+ return;
+ }
+
+ parts->scheme =
+ UTF8ComponentToWideComponent(text_utf8, parts_utf8.scheme);
+ parts ->username =
+ UTF8ComponentToWideComponent(text_utf8, parts_utf8.username);
+ parts->password =
+ UTF8ComponentToWideComponent(text_utf8, parts_utf8.password);
+ parts->host =
+ UTF8ComponentToWideComponent(text_utf8, parts_utf8.host);
+ parts->port =
+ UTF8ComponentToWideComponent(text_utf8, parts_utf8.port);
+ parts->path =
+ UTF8ComponentToWideComponent(text_utf8, parts_utf8.path);
+ parts->query =
+ UTF8ComponentToWideComponent(text_utf8, parts_utf8.query);
+ parts->ref =
+ UTF8ComponentToWideComponent(text_utf8, parts_utf8.ref);
+}
+
+} // namespace
+
// does some basic fixes for input that we want to test for file-ness
static void PrepareStringForFileOps(const FilePath& text,
FilePath::StringType* output) {
@@ -469,14 +516,18 @@ string URLFixerUpper::FixupRelativeFile(const FilePath& base_dir,
// Deprecated functions. To be removed when all callers are updated.
wstring URLFixerUpper::SegmentURL(const wstring& text,
url_parse::Parsed* parts) {
- return UTF8ToWide(SegmentURL(WideToUTF8(text), parts));
+ string text_utf8 = WideToUTF8(text);
+ url_parse::Parsed parts_utf8;
+ string scheme_utf8 = SegmentURL(text_utf8, &parts_utf8);
+ UTF8PartsToWideParts(text_utf8, parts_utf8, parts);
+ return UTF8ToWide(scheme_utf8);
}
wstring URLFixerUpper::FixupURL(const wstring& text,
- const wstring& desired_tld) {
+ const wstring& desired_tld) {
return UTF8ToWide(FixupURL(WideToUTF8(text), WideToUTF8(desired_tld)));
}
wstring URLFixerUpper::FixupRelativeFile(const wstring& base_dir,
- const wstring& text) {
+ const wstring& text) {
return UTF8ToWide(FixupRelativeFile(FilePath::FromWStringHack(base_dir),
FilePath::FromWStringHack(text)));
}
diff --git a/chrome/browser/net/url_fixer_upper.h b/chrome/browser/net/url_fixer_upper.h
index 9e29e47..7b6332d 100644
--- a/chrome/browser/net/url_fixer_upper.h
+++ b/chrome/browser/net/url_fixer_upper.h
@@ -26,7 +26,6 @@ namespace URLFixerUpper {
// Deprecated temporary compatibility function.
std::wstring SegmentURL(const std::wstring& text, url_parse::Parsed* parts);
-
// Converts |text| to a fixed-up URL and returns it. Attempts to make
// some "smart" adjustments to obviously-invalid input where possible.
// |text| may be an absolute path to a file, which will get converted to a