summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-30 21:00:27 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-30 21:00:27 +0000
commit6eac1b3e62b46946670e89bc259796b61b01d251 (patch)
tree8f99cafbf21b6bce0bfcf55d44c8ea93ad18a346 /chrome/browser/bookmarks
parenta728a359310e52d11cae7aa7e0a53960ed12b08a (diff)
downloadchromium_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 &quot; 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/bookmarks')
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer.cc4
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer_unittest.cc17
2 files changed, 15 insertions, 6 deletions
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());
}