Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/librustdoc/passes/lint/html_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ impl TagParser {
} else {
if !self.tag_name.is_empty() {
self.in_attrs = true;
// range of the entire tag within dox
let mut r = Range { start: range.start + start_pos, end: range.start + pos };
if c == '>' {
// In case we have a tag without attribute, we can consider the span to
Expand All @@ -381,7 +382,7 @@ impl TagParser {
for (new_pos, c) in text[pos..].char_indices() {
if !c.is_whitespace() {
if c == '>' {
r.end = range.start + new_pos + 1;
r.end = range.start + pos + new_pos + 1;
found = true;
} else if c == '<' {
self.handle_lt_in_tag(range.clone(), pos + new_pos, f);
Expand Down
25 changes: 25 additions & 0 deletions tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// this test ensures that bad HTML with multiline tags doesn't cause an ICE
// regression test for https://github.com/rust-lang/rust/issues/146890
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also explain what it's actually testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what extra info you want. It's testing to make sure this html doesn't cause an ICE. I understand what the bug was, but I don't entirely understand why it's so hard to reproduce.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This test ensures that bad HTML doesn't trigger an ICE."

#[deny(rustdoc::invalid_html_tags)]

/// <TABLE
/// BORDER>
/// <TR
/// >
/// <TH
//~^ ERROR: unclosed HTML tag `TH`
/// >key
/// </TD
//~^ ERROR: unopened HTML tag `TD`
/// >
/// <TH
//~^ ERROR: unclosed HTML tag `TH`
/// >value
/// </TD
//~^ ERROR: unopened HTML tag `TD`
/// >
/// </TR
/// >
/// </TABLE
/// >
pub fn foo() {}
38 changes: 38 additions & 0 deletions tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
error: unopened HTML tag `TD`
--> $DIR/invalid-html-tags-ice-146890.rs:12:5
|
LL | /// </TD
| _____^
LL | |
LL | | /// >
| |_____^
|
note: the lint level is defined here
--> $DIR/invalid-html-tags-ice-146890.rs:3:8
|
LL | #[deny(rustdoc::invalid_html_tags)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unopened HTML tag `TD`
--> $DIR/invalid-html-tags-ice-146890.rs:18:5
|
LL | /// </TD
| _____^
LL | |
LL | | /// >
| |_____^

error: unclosed HTML tag `TH`
--> $DIR/invalid-html-tags-ice-146890.rs:9:5
|
LL | /// <TH
| ^^^

error: unclosed HTML tag `TH`
--> $DIR/invalid-html-tags-ice-146890.rs:15:5
|
LL | /// <TH
| ^^^

error: aborting due to 4 previous errors

Loading