Rollup merge of #68263 - ollie27:rustdoc_invalid_syntax_highlight_escape, r=GuillaumeGomez

rustdoc: HTML escape codeblocks which fail syntax highlighting

r? @GuillaumeGomez
This commit is contained in:
Dylan DPC 2020-01-16 20:53:30 +05:30 committed by GitHub
commit 6e797ff8d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -65,7 +65,7 @@ pub fn render_with_highlighting(
Err(()) => {
// If errors are encountered while trying to highlight, just emit
// the unhighlighted source.
write!(out, "<pre><code>{}</code></pre>", src).unwrap();
write!(out, "<pre><code>{}</code></pre>", Escape(src)).unwrap();
}
}

View File

@ -25,3 +25,11 @@ pub fn quux() {}
/// \_
/// ```
pub fn ok() {}
// @has bad_codeblock_syntax/fn.escape.html
// @has - '//*[@class="docblock"]/pre/code' '\_ <script>alert("not valid Rust");</script>'
/// ```
/// \_
/// <script>alert("not valid Rust");</script>
/// ```
pub fn escape() {}