Bug 806460 - Part 1: NS_ERROR_ILLEGAL_VALUE in nsINavBookmarksService.insertBookmark while inserting query. r=gps

* * *
Bug 806460 - Part 2: more nuanced rejection of malformed records. r=me (fix bustage).
This commit is contained in:
Richard Newman 2012-10-29 15:24:52 -07:00
parent 10488462a7
commit 1a5b4a0eb1
2 changed files with 26 additions and 1 deletions

View File

@ -434,7 +434,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.
@ -499,6 +499,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);

View File

@ -384,6 +384,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();