M12: XFA template parsing options built for each parse

roxmltree's ParsingOptions on main is no longer Copy, so the options used for the
template and again for the expanded template are built for each parse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
This commit is contained in:
mtlcl410andClaude Opus 5.5 committed 2026-11-01 23:01:04 +08:00
1 parent 111c8f64e0
commit 607a5c26cd
1 file changed
+3 -3
+3 -3
View File
@@ -725,8 +725,8 @@ pub fn parse(xml: &str) -> Result<(Template, Vec<String>), XfaError> {
crate::MAX_XML_DEPTH
)));
}
let opts = roxmltree::ParsingOptions { allow_dtd: false, nodes_limit: MAX_NODES, ..Default::default() };
let doc = roxmltree::Document::parse_with_options(xml, opts).map_err(|e| XfaError::Malformed(format!("template XML: {e}")))?;
let opts = || roxmltree::ParsingOptions { allow_dtd: false, nodes_limit: MAX_NODES, ..Default::default() };
let doc = roxmltree::Document::parse_with_options(xml, opts()).map_err(|e| XfaError::Malformed(format!("template XML: {e}")))?;
let root = doc.root_element();
// The XDP's config packet has a <template> element too: the one we want is in the
// xfa-template namespace, or at least has a subform in it.
@@ -744,7 +744,7 @@ pub fn parse(xml: &str) -> Result<(Template, Vec<String>), XfaError> {
// written again with them merged in. The saved state below still comes from `doc`.
let (expanded, mut warnings) = crate::proto::expand(template);
let expanded_doc;
let template = match expanded.as_deref().map(|x| roxmltree::Document::parse_with_options(x, opts)) {
let template = match expanded.as_deref().map(|x| roxmltree::Document::parse_with_options(x, opts())) {
Some(Ok(d)) => {
expanded_doc = d;
expanded_doc.root_element()