tamer: ir::xir::reader: Disable quick-xml check_end_names
XIR must support tag mismatches; XIRT will validate them. This is currently disabled in the linker's xmlo reader as well. DEV-10863main
parent
d72ab3675c
commit
e6f53c20fd
|
@ -65,8 +65,15 @@ pub struct XmlXirReader<B: BufRead> {
|
||||||
|
|
||||||
impl<B: BufRead> XmlXirReader<B> {
|
impl<B: BufRead> XmlXirReader<B> {
|
||||||
pub fn new(reader: B) -> Self {
|
pub fn new(reader: B) -> Self {
|
||||||
|
let mut reader = quick_xml::Reader::from_reader(reader);
|
||||||
|
|
||||||
|
// XIR must support mismatched tags so that we are able to represent
|
||||||
|
// and reconstruct malformed inputs.
|
||||||
|
// XIRT will handle mismatch errors itself.
|
||||||
|
reader.check_end_names(false);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
reader: quick_xml::Reader::from_reader(reader),
|
reader,
|
||||||
readbuf: Vec::new(),
|
readbuf: Vec::new(),
|
||||||
// This capacity is largely arbitrary,
|
// This capacity is largely arbitrary,
|
||||||
// but [`Token`]s are small enough that it likely does not
|
// but [`Token`]s are small enough that it likely does not
|
||||||
|
|
|
@ -373,6 +373,24 @@ lines-->
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XIRT handles mismatch errors; XIR must explicitly support them.
|
||||||
|
#[test]
|
||||||
|
fn permits_mismatched_tags() {
|
||||||
|
let sut = Sut::new(r#"<root><child /></mismatch>"#.as_bytes());
|
||||||
|
|
||||||
|
let result = sut.collect::<Result<Vec<_>>>();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
result.expect("parsing failed"),
|
||||||
|
vec![
|
||||||
|
Token::Open("root".unwrap_into(), DUMMY_SPAN),
|
||||||
|
Token::Open("child".unwrap_into(), DUMMY_SPAN),
|
||||||
|
Token::Close(None, DUMMY_SPAN),
|
||||||
|
Token::Close(Some("mismatch".unwrap_into()), DUMMY_SPAN),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Enough information for error recovery and reporting.
|
// TODO: Enough information for error recovery and reporting.
|
||||||
#[test]
|
#[test]
|
||||||
fn node_name_invalid_utf8() {
|
fn node_name_invalid_utf8() {
|
||||||
|
|
Loading…
Reference in New Issue