Closed CryZe closed 7 years ago
Thanks for the issue! Iĺl look at this asap.
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 len >= buf_start + 3
for example (at least that's what it should be to not panic). So it probably makes sense for you to put in the proper logic, now that you know what the bug is.
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 Thanks again for the issue!!
When parsing the following XML
with
reader.trim_text(true);
, then it panics with: