summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer.cc4
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer_unittest.cc17
-rw-r--r--chrome/browser/importer/firefox2_importer.cc23
-rw-r--r--chrome/browser/importer/firefox_importer_unittest.cc10
5 files changed, 45 insertions, 11 deletions
diff --git a/AUTHORS b/AUTHORS
index 8192e79..bec4735 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -43,4 +43,4 @@ Joel Stanley <joel@jms.id.au>
Jacob Mandelson <jacob@mandelson.org>
Yuri Gorobets <yuri.gorobets@gmail.com>
Paul Wicks <pwicks86@gmail.com>
-
+Thiago Farina <thiago.farina@gmail.com>
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc
index 7418df6..9783d73 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer.cc
@@ -166,12 +166,12 @@ class Writer : public Task {
switch (type) {
case ATTRIBUTE_VALUE:
- // Convert " to \"
+ // Convert " to &quot;
if (text.find(L"\"") != std::wstring::npos) {
string16 replaced_string = WideToUTF16Hack(text);
ReplaceSubstringsAfterOffset(&replaced_string, 0,
ASCIIToUTF16("\""),
- ASCIIToUTF16("\\\""));
+ ASCIIToUTF16("&quot;"));
utf8_string = UTF16ToUTF8(replaced_string);
} else {
utf8_string = WideToUTF8(text);
diff --git a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc
index a47e204..bfb5a5b 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc
@@ -65,6 +65,7 @@ TEST_F(BookmarkHTMLWriterTest, Test) {
// F2
// url2
// url3
+ // url4
// Other
// url1
// url2
@@ -78,13 +79,16 @@ TEST_F(BookmarkHTMLWriterTest, Test) {
std::wstring url1_title = L"url 1";
std::wstring url2_title = L"url&2";
std::wstring url3_title = L"url\"3";
+ std::wstring url4_title = L"url\"&;";
GURL url1("http://url1");
GURL url2("http://url2");
GURL url3("http://url3");
+ GURL url4("http://\"&;\"");
BookmarkModel model(NULL);
base::Time t1(base::Time::Now());
base::Time t2(t1 + base::TimeDelta::FromHours(1));
base::Time t3(t1 + base::TimeDelta::FromHours(1));
+ base::Time t4(t1 + base::TimeDelta::FromHours(1));
const BookmarkNode* f1 = model.AddGroup(
model.GetBookmarkBarNode(), 0, f1_title);
model.AddURLWithCreationTime(f1, 0, url1_title, url1, t1);
@@ -98,6 +102,8 @@ TEST_F(BookmarkHTMLWriterTest, Test) {
const BookmarkNode* f3 = model.AddGroup(model.other_node(), 2, f3_title);
const BookmarkNode* f4 = model.AddGroup(f3, 0, f4_title);
model.AddURLWithCreationTime(f4, 0, url1_title, url1, t1);
+ model.AddURLWithCreationTime(model.GetBookmarkBarNode(), 2, url4_title,
+ url4, t4);
// Write to a temp file.
bookmark_html_writer::WriteBookmarks(NULL, &model, path_.ToWStringHack());
@@ -109,7 +115,7 @@ TEST_F(BookmarkHTMLWriterTest, Test) {
NULL, NULL);
// Verify we got back what we wrote.
- ASSERT_EQ(6U, parsed_bookmarks.size());
+ ASSERT_EQ(7U, parsed_bookmarks.size());
// Hardcode the value of IDS_BOOKMARK_BAR_FOLDER_NAME in en-US locale
// because all the unit tests are run in en-US locale.
const wchar_t* kBookmarkBarFolderName = L"Bookmarks bar";
@@ -120,10 +126,13 @@ TEST_F(BookmarkHTMLWriterTest, Test) {
AssertBookmarkEntryEquals(parsed_bookmarks[2], false, url3, url3_title, t3,
kBookmarkBarFolderName, std::wstring(),
std::wstring());
- AssertBookmarkEntryEquals(parsed_bookmarks[3], false, url1, url1_title, t1,
+ AssertBookmarkEntryEquals(parsed_bookmarks[3], false, url4, url4_title, t4,
+ kBookmarkBarFolderName, std::wstring(),
+ std::wstring());
+ AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1,
std::wstring(), std::wstring(), std::wstring());
- AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url2, url2_title, t2,
+ AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2,
std::wstring(), std::wstring(), std::wstring());
- AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url1, url1_title, t1,
+ AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1,
f3_title, f4_title, std::wstring());
}
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=&quot;\"\">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>",