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

Invalid close tag is parsed successfully #622

Closed
Aaron1011 opened this issue Jul 4, 2023 · 1 comment · Fixed by #679
Closed

Invalid close tag is parsed successfully #622

Aaron1011 opened this issue Jul 4, 2023 · 1 comment · Fixed by #679

Comments

@Aaron1011
Copy link
Contributor

Parsing the string "><" produces Event::Text(BytesText { content: Borrowed(">") }) followed by Event::Eof. However, this is an invalid XML string, and should result in some kind of error (or detectable error condition).

Reproduction:

use quick_xml::Reader;
use quick_xml::events::Event;

fn main() {
    
    let mut reader = Reader::from_str("><");
    reader.trim_text(true);
    
    loop {
        let event = reader.read_event().expect("Failed to read event");
        eprintln!("Event: {event:?}");
        if let Event::Eof = event {
            break;
        }
    }
}

outputs:

Event: Text(BytesText { content: Borrowed(">") })
Event: Eof
@Mingun
Copy link
Collaborator

Mingun commented Sep 18, 2023

To be clear: error here is only in emitting Event::Eof instead raising error about incomplete markup. > in the beginning correctly recognized as a text, because the only symbols that MUST be escaped in text in XML is < and & (see definition of CharData)

Mingun added a commit to Mingun/quick-xml that referenced this issue Nov 12, 2023
Mingun added a commit to Mingun/quick-xml that referenced this issue Nov 12, 2023
Mingun added a commit to Mingun/quick-xml that referenced this issue Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants