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

Unified Diff: chrome/browser/extensions/extension_bookmarks_module.cc

Issue 3672003: fix bookmarks API crash when handling invalid URL (Closed)
Patch Set: missing semicolon Created 10 years, 2 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/browser/extensions/extension_bookmarks_module.cc
diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc
index 991ea2d598e6ee39c421e1f065bac3e284336cab..1f6e4ee3fb1388042981ebbd12d59fd43deb6d2a 100644
--- a/chrome/browser/extensions/extension_bookmarks_module.cc
+++ b/chrome/browser/extensions/extension_bookmarks_module.cc
@@ -545,20 +545,17 @@ bool UpdateBookmarkFunction::RunImpl() {
DictionaryValue* updates;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &updates));
- string16 title;
- std::string url_string;
-
// Optional but we need to distinguish non present from an empty title.
+ string16 title;
const bool has_title = updates->GetString(keys::kTitleKey, &title);
- updates->GetString(keys::kUrlKey, &url_string); // Optional.
-
- GURL url;
- if (!url_string.empty()) {
- url = GURL(url_string);
- // If URL is present then it needs to be a non empty valid URL.
- EXTENSION_FUNCTION_VALIDATE(!url.is_empty());
- EXTENSION_FUNCTION_VALIDATE(url.is_valid());
+ // Optional.
+ std::string url_string;
+ updates->GetString(keys::kUrlKey, &url_string);
+ GURL url(url_string);
+ if (!url_string.empty() && !url.is_valid()) {
+ error_ = keys::kInvalidUrlError;
+ return false;
}
BookmarkModel* model = profile()->GetBookmarkModel();
« no previous file with comments | « chrome/browser/extensions/extension_bookmarks_apitest.cc ('k') | chrome/renderer/resources/extension_apitest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698