Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing instructions with embedded XML are not parsed correctly #706

Open
tajtiattila opened this issue Jan 16, 2024 · 0 comments
Open

Comments

@tajtiattila
Copy link

I have XML input that contains XML within processing instructions. See the test code below.

As far as I can tell, these are well-formed according to the spec at https://www.w3.org/TR/xml11/#sec-pi and such XMLs can be successfully parsed with xml-rs and rapidxml in C++.

I looked into it but I am not yet proficient with macros, and I couldn't figure out if one should use &[u8] instead of u8 for XmlSource::read_bytes_until or have another method like XmlSource::read_bytes_until_slice. I found that the memchr crate seems to have explicit support for two bytes and also for slices in general.

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn test_procinst_xml() {
        let xml = r#"<?xml version="1.0" encoding="utf-8"?>
<?procinst-with-xml
	<parameters>
		<parameter id="version" value="0.1"/>
		<parameter id="timeStamp" value="2024-01-16T10:44:00Z"/>
	</parameters>
?>
<Document/>"#;
        let mut reader = Reader::from_str(xml);
        loop {
            match reader.read_event() {
                Err(e) => panic!("Error at position {}: {:?}", reader.buffer_position(), e),
                Ok(Event::Eof) => break,
                _ => (),
            }
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant