Merge pull request #7779 from FredApps/chore/778-xfa-merged-pin

Use merged XFA namespace and BOM safety fixes
This commit is contained in:
FredApps authored and GitHub committed 2026-11-19 00:57:14 +07:00
commit bad6ac7fa2
4 files changed
+22 -5

No files matched your search

Generated
+3 -3
View File
@@ -1569,9 +1569,9 @@ dependencies = [
[[package]]
name = "craft-xfa"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=1a0d5d607859a2e529851482de09b8e53aaeec3e#1a0d5d607859a2e529851482de09b8e53aaeec3e"
source = "git+https://github.com/storytold/craft-libs?rev=23acc704933a9a5619a5cd1cddc9bb1fb5a9b2d3#23acc704933a9a5619a5cd1cddc9bb1fb5a9b2d3"
dependencies = [
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=1a0d5d607859a2e529851482de09b8e53aaeec3e)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=23acc704933a9a5619a5cd1cddc9bb1fb5a9b2d3)",
]
[[package]]
@@ -1586,7 +1586,7 @@ dependencies = [
[[package]]
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=1a0d5d607859a2e529851482de09b8e53aaeec3e#1a0d5d607859a2e529851482de09b8e53aaeec3e"
source = "git+https://github.com/storytold/craft-libs?rev=23acc704933a9a5619a5cd1cddc9bb1fb5a9b2d3#23acc704933a9a5619a5cd1cddc9bb1fb5a9b2d3"
dependencies = [
"quick-xml 0.41.0",
"serde",
+1 -1
View File
@@ -11,7 +11,7 @@ repository.workspace = true
workspace = true
[dependencies]
craft-xfa = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "1a0d5d607859a2e529851482de09b8e53aaeec3e" }
craft-xfa = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "23acc704933a9a5619a5cd1cddc9bb1fb5a9b2d3" }
pdfcraft-cos = { workspace = true }
pdfcraft-fonts = { workspace = true }
craft-xml = { workspace = true }
+9 -1
View File
@@ -193,7 +193,15 @@ pub fn parse_data_file(text: &str, expect_root: Option<&str>) -> Result<Vec<Impo
return Err(XfaError::TooLarge(format!("the data file nests more than {MAX_IMPORT_DEPTH} levels deep")));
}
let opts = crate::xml::ParsingOptions { allow_dtd: false, nodes_limit: MAX_NODES };
let parsed = crate::xml::Document::parse_with_options(text, opts).map_err(|e| XfaError::Malformed(format!("the data file is not XML: {e}")))?;
let parsed = crate::xml::Document::parse_with_options(text, opts).map_err(|e| {
// The pinned shared parser exposes string errors. Its namespace-copy admission
// limit is a resource refusal, not malformed XML; keep every other error distinct.
if e == "namespace retention budget exceeded" {
XfaError::TooLarge(format!("the data file exceeds the XML namespace retention budget: {e}"))
} else {
XfaError::Malformed(format!("the data file is not XML: {e}"))
}
})?;
let root = parsed.root_element();
let local = root.tag_name().name();
let in_xfa = |n: &crate::xml::Node| n.tag_name().namespace().is_none_or(|ns| ns == XFA_DATA_NS);
+9
View File
@@ -5239,6 +5239,15 @@ fn an_inherited_namespace_does_not_multiply_an_import() {
}
}
#[test]
fn data_import_keeps_malformed_xml_distinct_from_namespace_limits() {
use crate::data::parse_data_file;
for xml in ["<form1><a></form1>", "<form1><p:a/></form1>"] {
assert!(matches!(parse_data_file(xml, None), Err(XfaError::Malformed(_))), "{xml}");
}
let nodes = parse_data_file("<form1 xmlns:p='urn:small'><p:a>value</p:a></form1>", None).unwrap();
assert!(!nodes.is_empty());
}
/// A long data name with a high index is not copied into every sibling created before it.
#[test]
fn long_names_repeated_by_an_index_are_capped() {