mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-10 02:11:07 -06:00
Rewrite an unsigned file in full when saving after deleting pages (#3407)
This commit is contained in:
@@ -3945,6 +3945,11 @@ impl Session {
|
||||
// Signed documents are only ever saved incrementally: an edit that needs a full rewrite
|
||||
// (applying redactions, changing security, sanitizing) would invalidate the signatures.
|
||||
// So does any edit to a file rebuilt from object headers: it has no chain to append to.
|
||||
// Deleted pages are freed, but an incremental save keeps them (and their text) in the
|
||||
// earlier revision and the file does not shrink (#3407): rewrite an unsigned file in full.
|
||||
if !signed && matches!(edit, Edit::DeletePages { .. }) {
|
||||
next.require_full_save();
|
||||
}
|
||||
let rewrites = |c: &pdfcraft_cos::Document| c.full_save_required() || c.encryption_changed();
|
||||
if signed && ((rewrites(&next) && !rewrites(&editor.cos)) || (next.is_modified() && next.revisions().is_empty())) {
|
||||
return Err(EditError::SignedRewrite(edit.label().to_string()));
|
||||
|
||||
Reference in New Issue
Block a user