mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-20 19:18:41 +00:00
Merge pull request #7180 from rezaprama/fix/redact-unreadable-annotations
fix(redact): refuse annotations with unreadable bounds
This commit is contained in:
6 files changed
+257
-7
No files matched your search
@@ -5854,6 +5854,65 @@ fn redacting_through_tools() {
|
||||
assert!(matches!(a.call("redact_mark", &json!({ "doc": doc })), Err(ToolError::InvalidArgs(_))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn redact_apply_refuses_unreadable_annotations_then_recovers_through_tools() {
|
||||
for inline in [false, true] {
|
||||
for rect in ["", "/Rect [10 140 /Bad 80 160]"] {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let dir = temp.path();
|
||||
let note = format!("<< /Type /Annot /Subtype /Text /NM (problem-note) /Contents (PRIVATE-NOTE) {rect} >>");
|
||||
let annots = if inline { note.clone() } else { "6 0 R".into() };
|
||||
let page = format!(
|
||||
"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 300] /Contents 5 0 R \
|
||||
/Resources << /Font << /F1 4 0 R >> >> /Annots [{annots}] >>"
|
||||
);
|
||||
let content = "BT /F1 12 Tf 20 150 Td (SECRET) Tj ET BT /F1 12 Tf 20 50 Td (Public line) Tj ET";
|
||||
let stream = format!("<< /Length {} >>\nstream\n{content}\nendstream", content.len());
|
||||
let bytes = pdf_of(&[
|
||||
"<< /Type /Catalog /Pages 2 0 R >>",
|
||||
"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
|
||||
&page,
|
||||
"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",
|
||||
&stream,
|
||||
¬e,
|
||||
]);
|
||||
std::fs::write(dir.join("source.pdf"), bytes).unwrap();
|
||||
let mut a = auto(dir);
|
||||
let doc = ok(&mut a, "doc_open", json!({ "path": "source.pdf" }))["doc"].as_u64().unwrap();
|
||||
assert_eq!(ok(&mut a, "redact_mark", json!({ "doc": doc, "find": "SECRET" }))["marked"], 1);
|
||||
ok(&mut a, "doc_save", json!({ "doc": doc, "path": "pending.pdf", "full": true }));
|
||||
let state = |a: &Automation| {
|
||||
let d = a.session().get(pdfcraft_engine::DocId(doc)).unwrap();
|
||||
(d.bytes.clone(), d.dirty, d.edit_generation(), d.can_undo().map(str::to_owned), d.can_redo().map(str::to_owned))
|
||||
};
|
||||
let before = state(&a);
|
||||
let pending = std::fs::read(dir.join("pending.pdf")).unwrap();
|
||||
let comments = ok(&mut a, "comment_list", json!({ "doc": doc }));
|
||||
for _ in 0..2 {
|
||||
let failure = err(&mut a, "redact_apply", json!({ "doc": doc })).to_string();
|
||||
assert!(failure.contains("annotation 1 on page 1") && failure.contains("nothing was changed"), "{failure}");
|
||||
assert_eq!(state(&a), before, "refusal preserves working bytes, dirty state, generation and history");
|
||||
assert_eq!(ok(&mut a, "comment_list", json!({ "doc": doc })), comments, "the note and pending mark stay");
|
||||
assert_eq!(std::fs::read(dir.join("pending.pdf")).unwrap(), pending);
|
||||
assert!(page_text(&mut a, doc)[0].contains("SECRET"), "refusal leaves the original page intact");
|
||||
}
|
||||
// The error's remedy is reachable through the ordinary comment tool, even without a
|
||||
// usable rectangle. The original pending mark can then be applied and saved.
|
||||
ok(&mut a, "comment_delete", json!({ "doc": doc, "id": "problem-note" }));
|
||||
let applied = ok(&mut a, "redact_apply", json!({ "doc": doc }));
|
||||
assert_eq!((applied["applied"].as_u64(), applied["marks_pending"].as_u64()), (Some(1), Some(0)));
|
||||
ok(&mut a, "doc_save", json!({ "doc": doc, "path": "redacted.pdf", "full": true }));
|
||||
let mut reader = auto(dir);
|
||||
let reopened = ok(&mut reader, "doc_open", json!({ "path": "redacted.pdf" }))["doc"].as_u64().unwrap();
|
||||
let text = page_text(&mut reader, reopened)[0].clone();
|
||||
assert!(text.contains("Public line") && !text.contains("SECRET"), "{text}");
|
||||
assert_eq!(ok(&mut reader, "comment_list", json!({ "doc": reopened }))["comments"], json!([]));
|
||||
let saved = std::fs::read(dir.join("redacted.pdf")).unwrap();
|
||||
assert!(!saved.windows(b"PRIVATE-NOTE".len()).any(|w| w == b"PRIVATE-NOTE"), "the removed note must not survive a full save");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// #2539 review: `redact_apply` says where the removed text is still held that applying leaves as
|
||||
/// it is (a bookmark title and a note's text here), and changes neither.
|
||||
#[test]
|
||||
|
||||
@@ -65,7 +65,13 @@ clear_marks(&mut doc, None)?; // remove marks without app
|
||||
nothing paints inside the areas;
|
||||
- **form XObjects**: rewritten recursively into new objects (pages sharing the original keep it);
|
||||
- **annotations** whose rectangle overlaps (with their pop-ups and their replies, `/IRT`), and **form fields** with a
|
||||
widget under a mark;
|
||||
widget under a mark. On a selected page, a non-popup annotation with no readable `/Rect`
|
||||
(exactly four finite numbers, including referenced coordinates) refuses the entire operation
|
||||
with its page and annotation number. Repair or remove it before applying again; nothing changes
|
||||
on refusal. An unreadable rectangle is not treated as evidence that it misses the marks. An
|
||||
entry of `/Annots` that says it is something else (a `/Type` other than `/Annot` and no
|
||||
annotation `/Subtype`, such as a font a writer listed there) is not an annotation: it is kept
|
||||
and does not block Apply;
|
||||
- the marks themselves, replaced by boxes in their fill colour (and overlay text) drawn into the
|
||||
page as a `/PCMark /Redaction` stream;
|
||||
- **metadata** that repeats the removed text (#2448): `/Info` entries containing it or wholly
|
||||
|
||||
@@ -70,6 +70,12 @@ pub enum RedactError {
|
||||
"{0} redaction mark(s) have no readable area (neither usable QuadPoints nor a usable Rect), so the text under them can't be known; nothing was redacted. Remove those marks or mark the text again, then apply again"
|
||||
)]
|
||||
UnreadableMark(usize),
|
||||
/// An annotation's position cannot be judged. Keeping it could leave its text or appearance
|
||||
/// in a supposedly redacted file, so the caller must repair or remove it before applying.
|
||||
#[error(
|
||||
"annotation {annotation} on page {page} has no readable Rect of four finite numbers, so its overlap with the redaction marks can't be checked; repair or remove that annotation, then apply again (nothing was changed)"
|
||||
)]
|
||||
UnreadableAnnotation { page: usize, annotation: usize },
|
||||
#[error("redaction could not be verified: {0} item(s) were still found under the marks, so nothing was changed")]
|
||||
Residue(usize),
|
||||
/// A mark's overlay text has a character Helvetica can't draw; nothing was redacted.
|
||||
@@ -231,8 +237,11 @@ pub struct Report {
|
||||
}
|
||||
|
||||
pub(crate) fn rect_of(doc: &Document, o: Option<&Object>) -> Option<[f64; 4]> {
|
||||
let v: Vec<f64> = doc.resolve(o?).as_array()?.iter().filter_map(|x| doc.resolve(x).as_f64()).collect();
|
||||
(v.len() == 4 && v.iter().all(|x| x.is_finite())).then(|| [v[0].min(v[2]), v[1].min(v[3]), v[0].max(v[2]), v[1].max(v[3])])
|
||||
let obj = doc.resolve(o?);
|
||||
let [x0, y0, x1, y1] = obj.as_array()?.as_slice() else { return None };
|
||||
let [x0, y0, x1, y1] = [x0, y0, x1, y1].map(|x| doc.resolve(x).as_f64());
|
||||
let (x0, y0, x1, y1) = (x0?, y0?, x1?, y1?);
|
||||
[x0, y0, x1, y1].iter().all(|x| x.is_finite()).then(|| [x0.min(x1), y0.min(y1), x0.max(x1), y0.max(y1)])
|
||||
}
|
||||
|
||||
/// A mark's usable `/QuadPoints` quads ([`pdfcraft_geom::quad_points::usable_quads`]), the set the
|
||||
@@ -263,6 +272,47 @@ pub(crate) fn subtype(doc: &Document, d: &Dict) -> Option<Vec<u8>> {
|
||||
d.get(b"Subtype").and_then(|s| doc.resolve(s).as_name().map(<[u8]>::to_vec))
|
||||
}
|
||||
|
||||
/// The annotation types (ISO 32000-2 Table 171).
|
||||
const ANNOTATION_SUBTYPES: [&[u8]; 28] = [
|
||||
b"Text",
|
||||
b"Link",
|
||||
b"FreeText",
|
||||
b"Line",
|
||||
b"Square",
|
||||
b"Circle",
|
||||
b"Polygon",
|
||||
b"PolyLine",
|
||||
b"Highlight",
|
||||
b"Underline",
|
||||
b"Squiggly",
|
||||
b"StrikeOut",
|
||||
b"Caret",
|
||||
b"Stamp",
|
||||
b"Ink",
|
||||
b"Popup",
|
||||
b"FileAttachment",
|
||||
b"Sound",
|
||||
b"Movie",
|
||||
b"Screen",
|
||||
b"Widget",
|
||||
b"PrinterMark",
|
||||
b"TrapNet",
|
||||
b"Watermark",
|
||||
b"3D",
|
||||
b"Redact",
|
||||
b"Projection",
|
||||
b"RichMedia",
|
||||
];
|
||||
|
||||
/// Whether `d`, an entry of `/Annots` with `/Subtype` `kind`, says it is something other than an
|
||||
/// annotation: its `/Type` is a name that isn't `/Annot` (an annotation's, "if present, shall be
|
||||
/// Annot": ISO 32000-2 Table 166) and `kind` is no annotation type. A dictionary with an
|
||||
/// annotation type is an annotation whatever its `/Type` says, since a viewer may still show it.
|
||||
fn names_another_type(doc: &Document, d: &Dict, kind: &[u8]) -> bool {
|
||||
let other = d.get(b"Type").is_some_and(|t| doc.resolve(t).as_name().is_some_and(|n| n != b"Annot".as_slice()));
|
||||
other && !ANNOTATION_SUBTYPES.contains(&kind)
|
||||
}
|
||||
|
||||
/// The pop-up `d` names (`/Popup`), when it is one: it goes with `d`. Anything else it might name
|
||||
/// (a mark on another page, say) is left alone.
|
||||
fn named_popup(doc: &Document, d: &Dict) -> Option<ObjRef> {
|
||||
@@ -575,7 +625,7 @@ fn apply_within(doc: &mut Document, pages: Option<&[usize]>, images: pdfcraft_co
|
||||
let page = pdfcraft_model::pages(doc).swap_remove(pi);
|
||||
let rects: Vec<[f64; 4]> = page_marks.iter().flat_map(|m| m.rects.iter().copied()).collect();
|
||||
redact_page_content(doc, &mut applying, pi, &page, &rects)?;
|
||||
remove_page_annotations(doc, &mut applying, &page, &rects, page_marks)?;
|
||||
remove_page_annotations(doc, &mut applying, pi, &page, &rects, page_marks)?;
|
||||
}
|
||||
if applying.images.refused() > 0 {
|
||||
return Err(RedactError::ImagesPastAllowance);
|
||||
@@ -953,6 +1003,7 @@ fn redact_page_content(
|
||||
fn remove_page_annotations(
|
||||
doc: &mut Document,
|
||||
applying: &mut Applying,
|
||||
pi: usize,
|
||||
page: &pdfcraft_model::Page,
|
||||
rects: &[[f64; 4]],
|
||||
page_marks: &[&Mark],
|
||||
@@ -1004,7 +1055,15 @@ fn remove_page_annotations(
|
||||
if kind == b"Popup" {
|
||||
continue;
|
||||
}
|
||||
if rect_of(doc, d.get(b"Rect")).is_some_and(|b| rects.iter().any(|x| pdfcraft_content::overlaps(*x, b, 0.0))) {
|
||||
// A graphics state or a font that a writer listed in `/Annots` is not an annotation:
|
||||
// it has no `/Rect` to read and nothing a viewer shows, so it stays and Apply goes on.
|
||||
if names_another_type(doc, d, &kind) {
|
||||
continue;
|
||||
}
|
||||
// Unknown geometry is not evidence that the annotation misses every mark. Refuse rather
|
||||
// than keep potentially sensitive annotation text or appearances after a successful apply.
|
||||
let bounds = rect_of(doc, d.get(b"Rect")).ok_or(RedactError::UnreadableAnnotation { page: pi + 1, annotation: i + 1 })?;
|
||||
if rects.iter().any(|x| pdfcraft_content::overlaps(*x, bounds, 0.0)) {
|
||||
match r {
|
||||
Some(r) => removed.push(r),
|
||||
None => inline_gone[i] = true,
|
||||
|
||||
@@ -6394,6 +6394,7 @@ fn unused_descriptions_in_shared_or_inherited_resources_are_retired() {
|
||||
}
|
||||
}
|
||||
|
||||
mod annotation_geometry;
|
||||
mod descriptions;
|
||||
mod elsewhere;
|
||||
mod form_matrix;
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn annotation_rectangles_do_not_skip_non_numeric_entries() {
|
||||
let doc = one_page(b"BT ET", "", vec![]);
|
||||
let rect = Object::Array(vec![Object::Int(10), Object::Int(100), Object::name("bad"), Object::Int(40), Object::Int(120)]);
|
||||
assert_eq!(rect_of(&doc, Some(&rect)), None);
|
||||
}
|
||||
|
||||
fn with_annotation(rect: Option<Object>, inline: bool) -> Document {
|
||||
let mut doc = one_page(b"BT /F1 10 Tf 10 100 Td (SECRET) Tj ET", "", vec![]);
|
||||
let mut annotation = Dict::from_iter([
|
||||
(b"Type".to_vec(), Object::name("Annot")),
|
||||
(b"Subtype".to_vec(), Object::name("Text")),
|
||||
(b"Contents".to_vec(), Object::String(pdfcraft_cos::PdfString::text("PRIVATE-NOTE"))),
|
||||
]);
|
||||
if let Some(rect) = rect {
|
||||
annotation.set(b"Rect".to_vec(), rect);
|
||||
}
|
||||
let annotation = if inline { Object::Dict(annotation) } else { Object::Ref(doc.add(Object::Dict(annotation))) };
|
||||
let page = pdfcraft_model::pages(&doc)[0].obj;
|
||||
doc.update_dict(page, |d| d.set(b"Annots".to_vec(), Object::Array(vec![annotation]))).unwrap();
|
||||
mark(&mut doc, 0, &[[0.0, 90.0, 100.0, 130.0]], "");
|
||||
doc
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unreadable_annotation_rectangles_refuse_apply_without_changing_the_document() {
|
||||
let number = |n| Object::Int(n);
|
||||
let bad = [
|
||||
None,
|
||||
Some(Object::Null),
|
||||
Some(Object::name("not-a-rectangle")),
|
||||
Some(Object::Ref(ObjRef::new(999, 0))),
|
||||
Some(Object::Array(vec![number(10), number(100), number(40)])),
|
||||
Some(Object::Array(vec![number(10), number(100), Object::name("bad"), number(120)])),
|
||||
Some(Object::Array(vec![number(10), number(100), Object::name("bad"), number(40), number(120)])),
|
||||
Some(Object::Array(vec![number(10), number(100), Object::Real(f64::INFINITY), number(120)])),
|
||||
];
|
||||
for inline in [false, true] {
|
||||
for rect in &bad {
|
||||
let mut doc = with_annotation(rect.clone(), inline);
|
||||
// Keep non-finite objects in memory for the check: a writer need not preserve them.
|
||||
let before_page = pdfcraft_model::pages(&doc)[0].dict.clone();
|
||||
let before_content = content(&doc, 0);
|
||||
let before_marks = marks(&doc);
|
||||
let result = apply(&mut doc, None);
|
||||
assert!(matches!(result, Err(RedactError::UnreadableAnnotation { page: 1, annotation: 1 })), "{rect:?}, inline={inline}: {result:?}");
|
||||
assert_eq!(pdfcraft_model::pages(&doc)[0].dict, before_page);
|
||||
assert_eq!(content(&doc, 0), before_content);
|
||||
assert_eq!(marks(&doc), before_marks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn readable_annotation_rectangles_keep_their_geometry_and_save_without_the_note() {
|
||||
for inline in [false, true] {
|
||||
for indirect in [false, true] {
|
||||
let mut doc = with_annotation(Some(Object::Array(vec![Object::Int(40), Object::Int(120), Object::Int(10), Object::Int(100)])), inline);
|
||||
if indirect {
|
||||
let coordinates: Vec<Object> = [40, 120, 10, 100].into_iter().map(|n| Object::Ref(doc.add(Object::Int(n)))).collect();
|
||||
let rect = doc.add(Object::Array(coordinates));
|
||||
let page = pdfcraft_model::pages(&doc)[0].clone();
|
||||
let mut annots = annots_of(&doc, &page.dict);
|
||||
let mut annotation = doc.resolve(&annots[0]).as_dict().unwrap().clone();
|
||||
annotation.set(b"Rect".to_vec(), Object::Ref(rect));
|
||||
annots[0] = if inline { Object::Dict(annotation) } else { Object::Ref(doc.add(Object::Dict(annotation))) };
|
||||
doc.update_dict(page.obj, |d| d.set(b"Annots".to_vec(), Object::Array(annots))).unwrap();
|
||||
}
|
||||
assert_eq!(apply(&mut doc, None).unwrap().annotations, 1);
|
||||
let bytes = write_full(&doc, &SaveOptions { object_streams: false, ..SaveOptions::default() }).unwrap();
|
||||
assert!(!bytes.windows(b"PRIVATE-NOTE".len()).any(|w| w == b"PRIVATE-NOTE"));
|
||||
let saved = Document::open(Arc::new(bytes)).unwrap();
|
||||
assert!(annots_of(&saved, &pdfcraft_model::pages(&saved)[0].dict).is_empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malformed_annotations_on_unselected_pages_do_not_block_apply() {
|
||||
let mut doc = pdf(vec![
|
||||
b"<< /Type /Catalog /Pages 2 0 R >>".to_vec(),
|
||||
b"<< /Type /Pages /Kids [3 0 R 4 0 R] /Count 2 >>".to_vec(),
|
||||
b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 300] /Contents 5 0 R >>".to_vec(),
|
||||
b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 300] /Contents 5 0 R /Annots [<< /Type /Annot /Subtype /Text /Contents (UNSELECTED-NOTE) >>] >>".to_vec(),
|
||||
stream("", b"BT ET"),
|
||||
]);
|
||||
mark(&mut doc, 0, &[[0.0, 0.0, 100.0, 100.0]], "");
|
||||
let before = pdfcraft_model::pages(&doc)[1].dict.clone();
|
||||
apply(&mut doc, Some(&[0])).unwrap();
|
||||
assert_eq!(pdfcraft_model::pages(&doc)[1].dict, before);
|
||||
}
|
||||
|
||||
/// A page whose `/Annots` is `annots`, with a mark over the lower left of the page.
|
||||
fn page_with_annots(annots: &str) -> Document {
|
||||
let mut doc = pdf(vec![
|
||||
b"<< /Type /Catalog /Pages 2 0 R >>".to_vec(),
|
||||
b"<< /Type /Pages /Kids [3 0 R] /Count 1 >>".to_vec(),
|
||||
format!("<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 300] /Contents 4 0 R /Annots [{annots}] >>").into_bytes(),
|
||||
stream("", b"BT ET"),
|
||||
]);
|
||||
mark(&mut doc, 0, &[[0.0, 90.0, 100.0, 130.0]], "");
|
||||
doc
|
||||
}
|
||||
|
||||
/// A graphics state and a font listed in `/Annots` (PDFBOX-5775's `Export.pdf` has both) are not
|
||||
/// annotations: Apply goes on, removes the note under the mark and leaves them where they were.
|
||||
#[test]
|
||||
fn dictionaries_of_another_type_in_annots_do_not_block_apply() {
|
||||
let others = "<< /Type /ExtGState /CA 1 >> << /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>";
|
||||
let mut doc = page_with_annots(&format!("{others} << /Type /Annot /Subtype /Text /Rect [10 100 40 120] /Contents (PRIVATE-NOTE) >>"));
|
||||
assert_eq!(apply(&mut doc, None).unwrap().annotations, 1);
|
||||
let left = annots_of(&doc, &pdfcraft_model::pages(&doc)[0].dict);
|
||||
let type_of = |a: &Object| doc.resolve(a).as_dict().and_then(|d| d.get(b"Type")?.as_name().map(<[u8]>::to_vec));
|
||||
assert_eq!(left.iter().filter_map(type_of).collect::<Vec<_>>(), [b"ExtGState".to_vec(), b"Font".to_vec()]);
|
||||
}
|
||||
|
||||
/// An annotation type under another `/Type` is still an annotation: without a `/Rect` it refuses.
|
||||
#[test]
|
||||
fn an_annotation_subtype_under_another_type_still_refuses_apply() {
|
||||
let mut doc = page_with_annots("<< /Type /Font /Subtype /Text /Contents (PRIVATE-NOTE) >>");
|
||||
let result = apply(&mut doc, None);
|
||||
assert!(matches!(result, Err(RedactError::UnreadableAnnotation { page: 1, annotation: 1 })), "{result:?}");
|
||||
}
|
||||
@@ -5930,8 +5930,8 @@ milestone = "M8"
|
||||
status = "shipped"
|
||||
commands = ["redact.apply"]
|
||||
tools = ["redact_apply"]
|
||||
evidence = ["crates/ui-egui/tests/it/redact.rs::marking_applying_and_clearing", "crates/engine/src/tests.rs::redaction_marks_apply_for_good_and_undo", "crates/automation/tests/it/automation.rs::redacting_through_tools", "crates/engine/src/tests.rs::the_renderer_check_refuses_text_still_shown_under_a_mark", "crates/redact/src/tests.rs::redacted_xobjects_do_not_survive_through_inherited_or_shared_resources", "crates/redact/src/tests.rs::redacted_text_does_not_survive_in_info_or_xmp", "crates/redact/src/tests.rs::metadata_is_cleared_when_the_removed_text_was_cut_short", "crates/redact/src/tests/metadata_fail_closed.rs::an_xmp_stream_whose_filter_data_is_corrupt_goes", "crates/redact/src/tests/elsewhere.rs::places_apply_leaves_that_still_hold_the_removed_text_are_counted_and_kept", "crates/engine/src/tests.rs::applied_redactions_report_a_bookmark_that_still_holds_the_removed_text", "crates/automation/tests/it/automation.rs::redact_apply_reports_places_that_still_hold_the_removed_text", "crates/ui-egui/tests/it/redact.rs::applying_says_where_the_removed_text_is_still_held", "crates/redact/src/tests/metadata_matching.rs::a_heading_tracked_with_tj_numbers_matches_the_metadata", "crates/redact/src/tests/metadata_matching.rs::unicode_forms_of_the_removed_text_match", "crates/redact/src/tests/metadata_matching.rs::a_utf16le_string_is_searched_as_utf16le", "crates/redact/src/tests/identification.rs::the_identification_of_a_removed_packet_is_written_back", "crates/automation/tests/it/automation.rs::redact_apply_reports_the_identification_written_back", "crates/ui-egui/tests/it/redact.rs::applying_says_the_pdfa_identification_was_written_back"]
|
||||
notes = "confirmation; one undo step; next save is a full rewrite. Document information entries that contain the removed text, and the document's and pages' XMP streams that do, are removed (#2448; matched without regard to case or spacing, by the whole run of removed text and by its words of three letters or digits or more, and a value wholly part of a run as whole words, each also compared by letters and digits alone (so spacing, hyphens and TJ tracking don't hide it), after NFKC and lower case, with FF FE strings read as UTF-16LE; fail-closed: all of it goes when the removed text can't be known in full (too much to collect or search for, a glyph whose text isn't known, a form removed unread), and an XMP packet goes when it can't be decoded strictly, is over 16 MiB or isn't UTF-8 or UTF-16). When the document's XMP goes, its PDF/A and PDF/UA identification is written back in a packet holding only that, value by value when each is a valid code that doesn't hold the removed text, else reported lost (Report::identification, the notification, redact_apply's identification); /Info entries that remain aren't mirrored into that packet. Bookmark titles, attachments (names, file names, descriptions), the comments that remain and other objects' XMP are not changed: applying counts those that still hold the removed text, and the notification and redact_apply's still_holding say where (Remove hidden information removes them); when the removed text couldn't be searched for, every such place holding any text is counted. Refused, with nothing changed, when the page still shows text under a mark afterwards: text in some predefined CMaps and rotated Type 3 fonts is not removed yet, so those documents cannot be redacted. Also refused on a page with an inline image the renderer reads no image for, since the operators after it can't be known, or with bytes the content parser can't read in its content or in a form under a mark, which can hide text other readers draw. Removed images and forms are unlinked from page-tree resources (own, inherited or shared) and from surviving forms' resources, not yet from annotation appearances or patterns"
|
||||
evidence = ["crates/redact/src/tests/annotation_geometry.rs::an_annotation_subtype_under_another_type_still_refuses_apply", "crates/redact/src/tests/annotation_geometry.rs::dictionaries_of_another_type_in_annots_do_not_block_apply", "crates/automation/tests/it/automation.rs::redact_apply_refuses_unreadable_annotations_then_recovers_through_tools", "crates/redact/src/tests/annotation_geometry.rs::unreadable_annotation_rectangles_refuse_apply_without_changing_the_document", "crates/redact/src/tests/annotation_geometry.rs::readable_annotation_rectangles_keep_their_geometry_and_save_without_the_note", "crates/ui-egui/tests/it/redact.rs::marking_applying_and_clearing", "crates/engine/src/tests.rs::redaction_marks_apply_for_good_and_undo", "crates/automation/tests/it/automation.rs::redacting_through_tools", "crates/engine/src/tests.rs::the_renderer_check_refuses_text_still_shown_under_a_mark", "crates/redact/src/tests.rs::redacted_xobjects_do_not_survive_through_inherited_or_shared_resources", "crates/redact/src/tests.rs::redacted_text_does_not_survive_in_info_or_xmp", "crates/redact/src/tests.rs::metadata_is_cleared_when_the_removed_text_was_cut_short", "crates/redact/src/tests/metadata_fail_closed.rs::an_xmp_stream_whose_filter_data_is_corrupt_goes", "crates/redact/src/tests/elsewhere.rs::places_apply_leaves_that_still_hold_the_removed_text_are_counted_and_kept", "crates/engine/src/tests.rs::applied_redactions_report_a_bookmark_that_still_holds_the_removed_text", "crates/automation/tests/it/automation.rs::redact_apply_reports_places_that_still_hold_the_removed_text", "crates/ui-egui/tests/it/redact.rs::applying_says_where_the_removed_text_is_still_held", "crates/redact/src/tests/metadata_matching.rs::a_heading_tracked_with_tj_numbers_matches_the_metadata", "crates/redact/src/tests/metadata_matching.rs::unicode_forms_of_the_removed_text_match", "crates/redact/src/tests/metadata_matching.rs::a_utf16le_string_is_searched_as_utf16le", "crates/redact/src/tests/identification.rs::the_identification_of_a_removed_packet_is_written_back", "crates/automation/tests/it/automation.rs::redact_apply_reports_the_identification_written_back", "crates/ui-egui/tests/it/redact.rs::applying_says_the_pdfa_identification_was_written_back"]
|
||||
notes = "A dictionary in Annots naming another Type and no standard annotation Subtype stays without blocking Apply; an annotation subtype still requires readable bounds even under a wrong Type. A non-popup annotation on a selected page whose Rect is not exactly four finite numbers refuses Apply with page and annotation numbers, leaving the document unchanged; valid referenced coordinates and reversed corners still work. confirmation; one undo step; next save is a full rewrite. Document information entries that contain the removed text, and the document's and pages' XMP streams that do, are removed (#2448; matched without regard to case or spacing, by the whole run of removed text and by its words of three letters or digits or more, and a value wholly part of a run as whole words, each also compared by letters and digits alone (so spacing, hyphens and TJ tracking don't hide it), after NFKC and lower case, with FF FE strings read as UTF-16LE; fail-closed: all of it goes when the removed text can't be known in full (too much to collect or search for, a glyph whose text isn't known, a form removed unread), and an XMP packet goes when it can't be decoded strictly, is over 16 MiB or isn't UTF-8 or UTF-16). When the document's XMP goes, its PDF/A and PDF/UA identification is written back in a packet holding only that, value by value when each is a valid code that doesn't hold the removed text, else reported lost (Report::identification, the notification, redact_apply's identification); /Info entries that remain aren't mirrored into that packet. Bookmark titles, attachments (names, file names, descriptions), the comments that remain and other objects' XMP are not changed: applying counts those that still hold the removed text, and the notification and redact_apply's still_holding say where (Remove hidden information removes them); when the removed text couldn't be searched for, every such place holding any text is counted. Refused, with nothing changed, when the page still shows text under a mark afterwards: text in some predefined CMaps and rotated Type 3 fonts is not removed yet, so those documents cannot be redacted. Also refused on a page with an inline image the renderer reads no image for, since the operators after it can't be known, or with bytes the content parser can't read in its content or in a form under a mark, which can hide text other readers draw. Removed images and forms are unlinked from page-tree resources (own, inherited or shared) and from surviving forms' resources, not yet from annotation appearances or patterns"
|
||||
|
||||
[[feature]]
|
||||
id = "protect.redact-glyph-removal"
|
||||
|
||||
Reference in new issue
Block a user