Allow DTDs by default

This commit is contained in:
132ikl 2025-03-09 01:07:11 -05:00
parent d5ad36df3d
commit e5ad2d21b7

View File

@ -17,8 +17,8 @@ impl Command for FromXml {
.input_output_types(vec![(Type::String, Type::record())]) .input_output_types(vec![(Type::String, Type::record())])
.switch("keep-comments", "add comment nodes to result", None) .switch("keep-comments", "add comment nodes to result", None)
.switch( .switch(
"allow-dtd", "disallow-dtd",
"parse documents with document type definitions (may cause denial-of-service)", "disallow parsing documents with DTDs (prevents exponential entity expansion attacks)",
None, None,
) )
.switch( .switch(
@ -55,7 +55,7 @@ string. This way content of every tag is always a table and is easier to parse"#
let head = call.head; let head = call.head;
let keep_comments = call.has_flag(engine_state, stack, "keep-comments")?; let keep_comments = call.has_flag(engine_state, stack, "keep-comments")?;
let keep_processing_instructions = call.has_flag(engine_state, stack, "keep-pi")?; let keep_processing_instructions = call.has_flag(engine_state, stack, "keep-pi")?;
let allow_dtd = call.has_flag(engine_state, stack, "allow-dtd")?; let allow_dtd = !call.has_flag(engine_state, stack, "disallow-dtd")?;
let info = ParsingInfo { let info = ParsingInfo {
span: head, span: head,
keep_comments, keep_comments,
@ -276,7 +276,7 @@ fn process_xml_parse_error(source: String, err: roxmltree::Error, span: Span) ->
make_xml_error("The root node was opened but never closed.", span) make_xml_error("The root node was opened but never closed.", span)
} }
roxmltree::Error::DtdDetected => make_xml_error( roxmltree::Error::DtdDetected => make_xml_error(
"XML document with DTD detected. DTDs are disabled by default due to security reasons.", "XML document with DTD detected.",
span span
), ),
roxmltree::Error::NodesLimitReached => { roxmltree::Error::NodesLimitReached => {