PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
fix(ui): enforce copy permission before reading bookmark styles
Livio Oswaldee6f2a017f85
diff --git a/crates/ui-egui/src/bookmark_styles_ui.rs b/crates/ui-egui/src/bookmark_styles_ui.rsindex 718e582f7..dcdcfc80e 100644--- a/crates/ui-egui/src/bookmark_styles_ui.rs+++ b/crates/ui-egui/src/bookmark_styles_ui.rs@@ -36,6 +36,13 @@ impl PdfCraftApp {/// largest is offered for level 1 when there is more than one (headings are larger than the/// text around them; a single style has no headings to tell apart).pub fn open_text_style_bookmarks(&mut self, id: DocId) {+ // The style list includes samples copied from the document's text. Enforce the PDF's+ // copy permission before extracting any of that text, not only when creating bookmarks.+ let can_copy = self.session.get(id).is_some_and(|d| d.permissions().is_none_or(|p| p.copy()));+ if !can_copy {+ self.notify_tr("Copying text and images is not permitted");+ return;+ }let styles = self.session.get(id).map(|d| d.text_styles()).unwrap_or_default();let first = (styles.len() > 1).then_some(0);self.text_style_draft = TextStyleDraft { doc: Some(id), styles, levels: [first, None, None, None] };