diff options
| author | Oliver Middleton <olliemail27@gmail.com> | 2020-02-29 23:39:26 +0000 |
|---|---|---|
| committer | Oliver Middleton <olliemail27@gmail.com> | 2020-03-01 00:15:44 +0000 |
| commit | 3c97f8ad12e38fb658a88bf9c0c72446987f2021 (patch) | |
| tree | 1540c510c00aa96404f66d0acd19804cc323d260 | |
| parent | 3eeefc21f1a3ed9755c072c83808ed5c087b8c9a (diff) | |
| download | rust-3c97f8ad12e38fb658a88bf9c0c72446987f2021.tar.gz rust-3c97f8ad12e38fb658a88bf9c0c72446987f2021.zip | |
rustdoc: HTML escape crate version
As `--crate-version` accepts arbitrary strings they need to be escaped.
| -rw-r--r-- | src/librustdoc/html/render.rs | 5 | ||||
| -rw-r--r-- | src/test/rustdoc/crate-version-escape.rs | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 6a23b230e12..92db95eae32 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -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) ); } } diff --git a/src/test/rustdoc/crate-version-escape.rs b/src/test/rustdoc/crate-version-escape.rs new file mode 100644 index 00000000000..2f91eea339b --- /dev/null +++ b/src/test/rustdoc/crate-version-escape.rs @@ -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>' |
