Skip to content

Commit 29f789f

Browse files
committed
rustdoc: fix treatment of backslash-escaped HTML
Try generating HTML for this markup: \<a href="https://example.com">example</a> It will produce text, not HTML, in both rustdoc's real HTML output and in the commonmark reference implementation: https://spec.commonmark.org/dingus/?text=%5C%3Ca%20href%3D%22https%3A%2F%2Fexample.com%22%3Eexample%3C%2Fa%3E
1 parent 98e1f04 commit 29f789f

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/librustdoc/passes/html_tags.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl<'a, 'tcx> DocVisitor for InvalidHtmlTagsLinter<'a, 'tcx> {
278278
for (event, range) in p {
279279
match event {
280280
Event::Start(Tag::CodeBlock(_)) => in_code_block = true,
281-
Event::Html(text) | Event::Text(text) if !in_code_block => {
281+
Event::Html(text) if !in_code_block => {
282282
extract_tags(&mut tags, &text, range, &mut is_in_comment, &report_diag)
283283
}
284284
Event::End(Tag::CodeBlock(_)) => in_code_block = false,

src/test/rustdoc-ui/invalid-html-tags.rs

+7
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,10 @@ pub fn k() {}
114114
/// Web Components style </unopened-tag>
115115
//~^ ERROR unopened HTML tag `unopened-tag`
116116
pub fn m() {}
117+
118+
/// backslashed \<a href="">
119+
pub fn no_error_1() {}
120+
121+
/// backslashed \<<a href="">
122+
//~^ ERROR unclosed HTML tag `a`
123+
pub fn p() {}

src/test/rustdoc-ui/invalid-html-tags.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,11 @@ error: unclosed HTML tag `dashed-tags`
9494
LL | /// Web Components style <dashed-tags>
9595
| ^^^^^^^^^^^^^
9696

97-
error: aborting due to 15 previous errors
97+
error: unclosed HTML tag `a`
98+
--> $DIR/invalid-html-tags.rs:121:19
99+
|
100+
LL | /// backslashed \<<a href="">
101+
| ^^
102+
103+
error: aborting due to 16 previous errors
98104

0 commit comments

Comments
 (0)