mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
rustdoc: HTML escape crate version
As `--crate-version` accepts arbitrary strings they need to be escaped.
This commit is contained in:
parent
3eeefc21f1
commit
3c97f8ad12
@ -1313,7 +1313,8 @@ impl Context {
|
||||
<p>Version {}</p>\
|
||||
</div>\
|
||||
<a id='all-types' href='index.html'><p>Back to index</p></a>",
|
||||
crate_name, version
|
||||
crate_name,
|
||||
Escape(version),
|
||||
)
|
||||
} else {
|
||||
String::new()
|
||||
@ -3974,7 +3975,7 @@ fn print_sidebar(cx: &Context, it: &clean::Item, buffer: &mut Buffer) {
|
||||
"<div class='block version'>\
|
||||
<p>Version {}</p>\
|
||||
</div>",
|
||||
version
|
||||
Escape(version)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
6
src/test/rustdoc/crate-version-escape.rs
Normal file
6
src/test/rustdoc/crate-version-escape.rs
Normal file
@ -0,0 +1,6 @@
|
||||
// compile-flags: --crate-version=<script>alert("hi")</script> -Z unstable-options
|
||||
|
||||
#![crate_name = "foo"]
|
||||
|
||||
// @has 'foo/index.html' '//div[@class="block version"]/p' 'Version <script>alert("hi")</script>'
|
||||
// @has 'foo/all.html' '//div[@class="block version"]/p' 'Version <script>alert("hi")</script>'
|
Loading…
Reference in New Issue
Block a user