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

Closed
tajtiattila opened this issue Jan 16, 2024 · 1 comment
Closed
Labels

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,
                _ => (),
            }
        }
    }
}
@Mingun Mingun added the bug label Jun 9, 2024
@Mingun
Copy link
Collaborator

Mingun commented Jun 9, 2024

Fixed by #753

@Mingun Mingun closed this as completed Jun 9, 2024
Mingun added a commit that referenced this issue Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants