Allow DTD in XML parsing (#3534)

This commit is contained in:
Myriad-Dreamin 2024-03-01 19:42:01 +08:00 committed by GitHub
parent 1e2c239971
commit dadd657e0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,5 @@
use ecow::EcoString;
use roxmltree::ParsingOptions;
use crate::diag::{format_xml_like_error, At, FileError, SourceResult};
use crate::engine::Engine;
@ -80,8 +81,12 @@ impl xml {
let text = std::str::from_utf8(data.as_slice())
.map_err(FileError::from)
.at(span)?;
let document =
roxmltree::Document::parse(text).map_err(format_xml_error).at(span)?;
let document = roxmltree::Document::parse_with_options(
text,
ParsingOptions { allow_dtd: true, ..Default::default() },
)
.map_err(format_xml_error)
.at(span)?;
Ok(convert_xml(document.root()))
}
}