Skip to content

Commit

Permalink
Bug 806460 - Part 1: NS_ERROR_ILLEGAL_VALUE in nsINavBookmarksService…
Browse files Browse the repository at this point in the history
….insertBookmark while inserting query. r=gps, a=lsblakk

* * *
Bug 806460 - Part 2: more nuanced rejection of malformed records. r=me (fix bustage).
  • Loading branch information
Richard Newman committed Oct 29, 2012
1 parent cdab4b8 commit b58f66d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 8 additions & 1 deletion services/sync/modules/engines/bookmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ BookmarksStore.prototype = {
preprocessTagQuery: function preprocessTagQuery(record) {
if (record.type != "query" ||
record.bmkUri == null ||
record.folderName == null)
!record.folderName)
return;

// Yes, this works without chopping off the "place:" prefix.
Expand Down Expand Up @@ -501,6 +501,13 @@ BookmarksStore.prototype = {
return;
}

// Skip malformed records. (Bug 806460.)
if (record.type == "query" &&
!record.bmkUri) {
this._log.warn("Skipping malformed query bookmark: " + record.id);
return;
}

// Preprocess the record before doing the normal apply.
this.preprocessTagQuery(record);

Expand Down
18 changes: 18 additions & 0 deletions services/sync/tests/unit/test_bookmark_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,24 @@ add_test(function test_reparentOrphans() {
}
});

// Tests Bug 806460, in which query records arrive with empty folder
// names and missing bookmark URIs.
add_test(function test_empty_query_doesnt_die() {
let record = new BookmarkQuery("bookmarks", "8xoDGqKrXf1P");
record.folderName = "";
record.queryId = "";
record.parentName = "Toolbar";
record.parentid = "toolbar";

// These should not throw.
store.applyIncoming(record);

delete record.folderName;
store.applyIncoming(record);

run_next_test();
});

function run_test() {
initTestLogging('Trace');
run_next_test();
Expand Down

0 comments on commit b58f66d

Please sign in to comment.