Skip to content

Commit a4febad

Browse files
committed
IllFormed(UnmatchedEnd) should be reported always because lone closed tags are not allowed even in HTML
1 parent 4d887a2 commit a4febad

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/reader/mod.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -1740,22 +1740,15 @@ mod test {
17401740
);
17411741
}
17421742

1743+
/// Lone closing tags are not allowed, so testing it together with start tag
17431744
#[$test]
1744-
$($async)? fn start() {
1745-
let mut reader = Reader::from_str("<tag>");
1745+
$($async)? fn start_and_end() {
1746+
let mut reader = Reader::from_str("<tag></tag>");
17461747

17471748
assert_eq!(
17481749
reader.$read_event($buf) $(.$await)? .unwrap(),
17491750
Event::Start(BytesStart::new("tag"))
17501751
);
1751-
}
1752-
1753-
#[$test]
1754-
$($async)? fn end() {
1755-
let mut reader = Reader::from_str("</tag>");
1756-
// Because we expect invalid XML, do not check that
1757-
// the end name paired with the start name
1758-
reader.check_end_names(false);
17591752

17601753
assert_eq!(
17611754
reader.$read_event($buf) $(.$await)? .unwrap(),

src/reader/state.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,14 @@ impl ReaderState {
170170

171171
self.opened_buffer.truncate(start);
172172
}
173-
None if self.check_end_names => {
173+
None => {
174174
// Report error at start of the end tag at `<` character
175175
// +2 for `<` and `>`
176176
self.offset -= buf.len() + 2;
177177
return Err(Error::IllFormed(IllFormedError::UnmatchedEnd(
178178
decoder.decode(name).unwrap_or_default().into_owned(),
179179
)));
180180
}
181-
None => {}
182181
}
183182

184183
Ok(Event::End(BytesEnd::wrap(name.into())))

0 commit comments

Comments
 (0)