diff --git a/crates/engine/src/session/files.rs b/crates/engine/src/session/files.rs index e927be71ba..47591ccbfe 100644 --- a/crates/engine/src/session/files.rs +++ b/crates/engine/src/session/files.rs @@ -102,10 +102,9 @@ impl Session { if format == DataFormat::Xdp && !xfa { return Err(EditError::Invalid("XDP holds XFA form data; this document is not an XFA form (use .xml, .csv or .txt)".into())); } - // The datasets are the form's content, copied out whole (Table 22, bit 5). - if xfa && matches!(format, DataFormat::Xml | DataFormat::Xdp) { - doc.check_copying()?; - } + // Comments and form data, the XFA datasets whole, are the document's content copied out + // of it (Table 22, bit 5), as the text exports are. + doc.check_copying()?; guard(|| match format { DataFormat::Xfdf => Ok(pdfcraft_xfdf::export_xfdf(&cos, comments, fields, &doc.name).into_bytes()), DataFormat::Fdf => pdfcraft_xfdf::export_fdf(&cos, comments, fields, &doc.name).map_err(|e| e.to_string()), diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index b1326b207e..bb62f87795 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -10252,9 +10252,9 @@ fn image_transform_engine_refuses_singular_matrices_without_mutation() { } } -/// An XFA form's datasets export (XML, XDP) copies the form's data out whole: a document whose -/// security settings withhold copying (Table 22, bit 5) refuses it, as the text exports do, -/// and the owner password lifts it. +/// Exporting comments or form data (an XFA form's datasets whole, as XML or XDP) copies them out +/// of the document: one whose security settings withhold copying (Table 22, bit 5) refuses it, +/// as the text exports do, and the owner password lifts it. #[test] fn xfa_data_export_needs_copying_permission() { let data = "
JP
"; @@ -10272,7 +10272,7 @@ fn xfa_data_export_needs_copying_permission() { let mut s = Session::new().with_clock(|| 1_700_000_000); let id = s.open("fields.pdf", None, bytes.clone(), None).unwrap(); assert!(s.get(id).unwrap().info.xfa.is_some() && !s.get(id).unwrap().allows_copying()); - for format in [DataFormat::Xml, DataFormat::Xdp] { + for format in [DataFormat::Xml, DataFormat::Xdp, DataFormat::Xfdf, DataFormat::Fdf] { assert_eq!(s.export_data(id, format, false, true).map(|_| ()), Err(EditError::NotPermitted("copying text and images"))); } let oid = s.open("fields.pdf", None, bytes, Some("owner")).unwrap();