Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4830)

Unified Diff: chrome/utility/importer/bookmark_html_reader.cc

Issue 1873403003: Read bookmarks from 'NETSCAPE-Bookmark-file's that don't have a beginning <DT> tag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/utility/importer/bookmark_html_reader.cc
diff --git a/chrome/utility/importer/bookmark_html_reader.cc b/chrome/utility/importer/bookmark_html_reader.cc
index a9edfebcc0e3d2c7c9ab59c5bb28ea0ecae9b9c6..68160218f6a8cece66df683740574a7e36f8553e 100644
--- a/chrome/utility/importer/bookmark_html_reader.cc
+++ b/chrome/utility/importer/bookmark_html_reader.cc
@@ -129,6 +129,16 @@ void ImportBookmarksFile(
base::TrimString(line, " ", &line);
}
+ // Remove "<DT>" if the line starts with "<DT>". This may not occur if
+ // "<DT>" was on the previous line. Liberally accept entries that do not
+ // have an opening "<DT>" at all.
+ static const char kDtTag[] = "<DT>";
+ if (base::StartsWith(line, kDtTag,
+ base::CompareCase::INSENSITIVE_ASCII)) {
Ilya Sherman 2016/04/13 00:11:11 nit: This indentation looks a bit off to me. Coul
Tom (Use chromium acct) 2016/04/14 01:43:56 Done.
+ line.erase(0, arraysize(kDtTag) - 1);
+ base::TrimString(line, " ", &line);
+ }
+
// Get the encoding of the bookmark file.
if (internal::ParseCharsetFromLine(line, &charset))
continue;
@@ -303,7 +313,7 @@ bool ParseFolderNameFromLine(const std::string& line,
base::string16* folder_name,
bool* is_toolbar_folder,
base::Time* add_date) {
- const char kFolderOpen[] = "<DT><H3";
+ const char kFolderOpen[] = "<H3";
const char kFolderClose[] = "</H3>";
const char kToolbarFolderAttribute[] = "PERSONAL_TOOLBAR_FOLDER";
const char kAddDateAttribute[] = "ADD_DATE";
@@ -351,7 +361,7 @@ bool ParseBookmarkFromLine(const std::string& line,
base::string16* shortcut,
base::Time* add_date,
base::string16* post_data) {
- const char kItemOpen[] = "<DT><A";
+ const char kItemOpen[] = "<A";
const char kItemClose[] = "</A>";
const char kFeedURLAttribute[] = "FEEDURL";
const char kHrefAttribute[] = "HREF";
@@ -434,7 +444,7 @@ bool ParseMinimumBookmarkFromLine(const std::string& line,
const std::string& charset,
base::string16* title,
GURL* url) {
- const char kItemOpen[] = "<DT><A";
+ const char kItemOpen[] = "<A";
const char kItemClose[] = "</";
const char kHrefAttributeUpper[] = "HREF";
const char kHrefAttributeLower[] = "href";
« no previous file with comments | « chrome/test/data/bookmark_html_reader/redditsaver.html ('k') | chrome/utility/importer/bookmark_html_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698