Chromium Code Reviews| 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..703b7af20379dc139d1a7f438c6d7b3d8075c59a 100644 |
| --- a/chrome/utility/importer/bookmark_html_reader.cc |
| +++ b/chrome/utility/importer/bookmark_html_reader.cc |
| @@ -91,6 +91,18 @@ void DataURLToFaviconUsage(const GURL& link_url, |
| namespace bookmark_html_reader { |
| +static void stripDt(std::string& 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)) { |
| + line.erase(0, arraysize(kDtTag) - 1); |
| + base::TrimString(line, " ", &line); |
| + } |
| +} |
| + |
| void ImportBookmarksFile( |
| const base::Callback<bool(void)>& cancellation_callback, |
| const base::Callback<bool(const GURL&)>& valid_url_callback, |
| @@ -298,16 +310,18 @@ bool ParseCharsetFromLine(const std::string& line, std::string* charset) { |
| return false; |
| } |
| -bool ParseFolderNameFromLine(const std::string& line, |
| +bool ParseFolderNameFromLine(std::string line, |
|
Ilya Sherman
2016/04/14 02:22:53
Even if you want to modify the variable in the met
Tom (Use chromium acct)
2016/04/14 17:21:44
Done.
|
| const std::string& charset, |
| 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"; |
| + stripDt(line); |
|
Ilya Sherman
2016/04/14 02:22:53
Hmm, why do you need to also strip DT tags here, r
Tom (Use chromium acct)
2016/04/14 17:21:44
I removed the code that strips the DT near where w
|
| + |
| if (!base::StartsWith(line, kFolderOpen, base::CompareCase::SENSITIVE)) |
| return false; |
| @@ -343,7 +357,7 @@ bool ParseFolderNameFromLine(const std::string& line, |
| return true; |
| } |
| -bool ParseBookmarkFromLine(const std::string& line, |
| +bool ParseBookmarkFromLine(std::string line, |
| const std::string& charset, |
| base::string16* title, |
| GURL* url, |
| @@ -351,7 +365,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"; |
| @@ -360,6 +374,7 @@ bool ParseBookmarkFromLine(const std::string& line, |
| const char kAddDateAttribute[] = "ADD_DATE"; |
| const char kPostDataAttribute[] = "POST_DATA"; |
| + stripDt(line); |
| title->clear(); |
| *url = GURL(); |
| *favicon = GURL(); |
| @@ -430,15 +445,16 @@ bool ParseBookmarkFromLine(const std::string& line, |
| return true; |
| } |
| -bool ParseMinimumBookmarkFromLine(const std::string& line, |
| +bool ParseMinimumBookmarkFromLine(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"; |
| + stripDt(line); |
| title->clear(); |
| *url = GURL(); |