diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-30 21:00:27 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-30 21:00:27 +0000 |
commit | 6eac1b3e62b46946670e89bc259796b61b01d251 (patch) | |
tree | 8f99cafbf21b6bce0bfcf55d44c8ea93ad18a346 /chrome/browser/importer | |
parent | a728a359310e52d11cae7aa7e0a53960ed12b08a (diff) | |
download | chromium_src-6eac1b3e62b46946670e89bc259796b61b01d251.zip chromium_src-6eac1b3e62b46946670e89bc259796b61b01d251.tar.gz chromium_src-6eac1b3e62b46946670e89bc259796b61b01d251.tar.bz2 |
Lands http://codereview.chromium.org/126036 for Thiago.
From Thiago:
This patch is to solve the problem in import/export bookmarks. They aren't
exported correctly and also not imported
correctly. Now when the bookmarks are exported the character " are escaped to
" and when they are imported,
they are unescaped.
BUG=7505
TEST=Try importing/exporting bookmarks, make sure nothing is broken.
Review URL: http://codereview.chromium.org/126222
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer')
-rw-r--r-- | chrome/browser/importer/firefox2_importer.cc | 23 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_importer_unittest.cc | 10 |
2 files changed, 29 insertions, 4 deletions
diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc index 0d6359e..7e680fb 100644 --- a/chrome/browser/importer/firefox2_importer.cc +++ b/chrome/browser/importer/firefox2_importer.cc @@ -447,8 +447,14 @@ bool Firefox2Importer::ParseBookmarkFromLine(const std::string& line, // URL if (GetAttribute(attribute_list, kHrefAttribute, &value)) { - ReplaceSubstringsAfterOffset(&value, 0, "%22", "\""); - *url = GURL(value); + std::wstring w_url; + CodepageToWide(value, charset.c_str(), OnStringUtilConversionError::SKIP, + &w_url); + HTMLUnescape(&w_url); + + string16 url16 = WideToUTF16Hack(w_url); + + *url = GURL(url16); } // Favicon @@ -491,8 +497,17 @@ bool Firefox2Importer::GetAttribute(const std::string& attribute_list, return false; // Can't find the attribute. begin = attribute_list.find(kQuote, begin) + 1; - size_t end = attribute_list.find(kQuote, begin); - if (end == std::string::npos) + + size_t end = begin + 1; + while (end < attribute_list.size()) { + if (attribute_list[end] == '"' && + attribute_list[end - 1] != '\\') { + break; + } + end++; + } + + if (end == attribute_list.size()) return false; // The value is not quoted. *value = attribute_list.substr(begin, end - begin); diff --git a/chrome/browser/importer/firefox_importer_unittest.cc b/chrome/browser/importer/firefox_importer_unittest.cc index e836a5a..ea4c37c 100644 --- a/chrome/browser/importer/firefox_importer_unittest.cc +++ b/chrome/browser/importer/firefox_importer_unittest.cc @@ -106,6 +106,16 @@ TEST(FirefoxImporterTest, Firefox2BookmarkParse) { EXPECT_EQ(L"", post_data); EXPECT_TRUE(Time() == add_date); + result = Firefox2Importer::ParseBookmarkFromLine( + "<DT><A HREF=\"http://domain.com/?g="\"\">name</A>", + charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); + EXPECT_TRUE(result); + EXPECT_EQ(L"name", title); + EXPECT_EQ("http://domain.com/?g=%22", url.spec()); + EXPECT_EQ(L"", shortcut); + EXPECT_EQ(L"", post_data); + EXPECT_TRUE(Time() == add_date); + // Creation date. result = Firefox2Importer::ParseBookmarkFromLine( "<DT><A HREF=\"http://site/\" ADD_DATE=\"1121301154\">name</A>", |