Skip to content

Commit

Permalink
Bug 1935797 - Reject updates of moz_bookmarks.type.
Browse files Browse the repository at this point in the history
  • Loading branch information
linabutler committed Dec 10, 2024
1 parent 29b5fd0 commit 5dfd0e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions components/places/sql/create_shared_triggers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ BEGIN
WHERE NEW.guid <> 'root________'
AND NOT EXISTS(
SELECT 1 FROM moz_bookmarks WHERE id = NEW.parent);

SELECT throw(format('update: old type=%d; new=%d', OLD.type, NEW.type))
WHERE OLD.type <> NEW.type;
END;

-- Triggers which update visit_count and last_visit_date based on historyvisits
Expand Down
17 changes: 17 additions & 0 deletions components/places/src/db/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,23 @@ mod tests {
e,
);
}

// Changing the type of an existing item.
{
let e = conn
.execute(
"UPDATE moz_bookmarks SET
type = 3
WHERE guid = 'folder_guid_'",
[],
)
.expect_err("should fail to update type of bookmark");
assert!(
e.to_string().contains("update: old type=2; new=3"),
"Expected error, got: {:?}",
e,
);
}
}

fn select_simple_int(conn: &PlacesDb, stmt: &str) -> u32 {
Expand Down

0 comments on commit 5dfd0e6

Please sign in to comment.