Skip to content

read_to_end breaks NsReader #597

Open
@roblabla

Description

@roblabla

Heyo,

The NsReader::read_to_end seems to break its ability to resolve namespaces. This makes sense looking at its implementation: It simply delegates to the underlying readers' implementation, without updating its NamespaceResolver:

pub fn read_to_end(&mut self, end: QName) -> Result<Span> {
// According to the https://www.w3.org/TR/xml11/#dt-etag, end name should
// match literally the start name. See `Self::check_end_names` documentation
self.reader.read_to_end(end)
}

Here's a reproducer:

    #[test]
    fn repro2() {
        const S: &'static str = r#"
<?xml version="1.0" encoding="UTF-8"?>
<oval_definitions xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5">

    <tests>
        <xmlfilecontent_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
        </xmlfilecontent_test>
        <xmlfilecontent_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
        </xmlfilecontent_test>
    </tests>
    <objects/>
</oval_definitions>"#;

        let mut reader = quick_xml::NsReader::from_str(S);
        let (ns, ev) = loop {
            let (ns, ev) = reader.read_resolved_event().unwrap();
            match ev {
                quick_xml::events::Event::Start(v) if v.local_name().as_ref() == b"xmlfilecontent_test" => {
                    reader.read_to_end(v.name()).unwrap();
                },
                quick_xml::events::Event::Empty(v) if v.local_name().as_ref() == b"objects" => break (ns, v),
                _ => (),
            }
        };
        assert_eq!(ns, quick_xml::name::ResolveResult::Bound(quick_xml::name::Namespace(b"http://oval.mitre.org/XMLSchema/oval-definitions-5")));
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnamespacesIssues related to namespaces support

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions