-
Notifications
You must be signed in to change notification settings - Fork 241
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
Panic when trim text is active #94
Comments
Thanks for the issue! |
I'm kinda trying to figure it out atm too, but you may be faster. Here's some code to reproduce it: extern crate quick_xml;
use quick_xml::reader::Reader;
use quick_xml::events::Event;
fn main() {
let src = br#"<Run>
<!B>
</Run>"#;
let mut reader = Reader::from_reader(&src[..]);
reader.trim_text(true);
let mut buf = Vec::new();
loop {
if let Event::Eof = reader.read_event(&mut buf).unwrap() {
break;
}
buf.clear();
}
} |
if len >= 3 && &buf[buf_start + 1..buf_start + 3] == b"--" { this line and other lines in the read_bang method implicitly assume that buf_start is 0. So the len check here should be Actually, maybe it makes sense to preslice the whole buf, so this can't even happen, instead of adding the buf_start to every indexing / range operation. |
yes, all these tests should be if len >= buf_start + x { ... } |
I have done it as well. Do you want to do a PR or I'll do it? |
nah, you should probably do it. I'm not familiar with all the specifics of the method enough to be comfortable with it being correct. |
sure, thanks! |
Nice, thank you :) |
Published v0.9.4 |
When parsing the following XML
with
reader.trim_text(true);
, then it panics with:The text was updated successfully, but these errors were encountered: