Rollup merge of #69598 - ollie27:rustdoc_crate-version_escape, r=GuillaumeGomez
rustdoc: HTML escape crate version As `--crate-version` accepts arbitrary strings they need to be escaped. r? @GuillaumeGomez
This commit is contained in:
commit
22a03913f4
2 changed files with 9 additions and 2 deletions
|
@ -1313,7 +1313,8 @@ impl Context {
|
||||||
<p>Version {}</p>\
|
<p>Version {}</p>\
|
||||||
</div>\
|
</div>\
|
||||||
<a id='all-types' href='index.html'><p>Back to index</p></a>",
|
<a id='all-types' href='index.html'><p>Back to index</p></a>",
|
||||||
crate_name, version
|
crate_name,
|
||||||
|
Escape(version),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
|
@ -3974,7 +3975,7 @@ fn print_sidebar(cx: &Context, it: &clean::Item, buffer: &mut Buffer) {
|
||||||
"<div class='block version'>\
|
"<div class='block version'>\
|
||||||
<p>Version {}</p>\
|
<p>Version {}</p>\
|
||||||
</div>",
|
</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…
Add table
Add a link
Reference in a new issue