diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2025-09-14 01:32:20 +0200 |
|---|---|---|
| committer | León Orell Valerian Liehr <me@fmease.dev> | 2025-09-25 11:30:58 +0200 |
| commit | d7d7725b8cbeea8db490c3b033773776ce8794f5 (patch) | |
| tree | dccb7c948e48bc87f72f4e8b1405cbeed45d5447 /tests/rustdoc/attributes.rs | |
| parent | 88e797784e21ecad4dc768109ede33c76293482e (diff) | |
| download | rust-d7d7725b8cbeea8db490c3b033773776ce8794f5.tar.gz rust-d7d7725b8cbeea8db490c3b033773776ce8794f5.zip | |
rustdoc: Fully escape link section and export name
Escape "special characters" (e.g., double quotes `"` and line breaks `\n`). Escape HTML. Lastly, add regression tests and clean up existing tests.
Diffstat (limited to 'tests/rustdoc/attributes.rs')
| -rw-r--r-- | tests/rustdoc/attributes.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/rustdoc/attributes.rs b/tests/rustdoc/attributes.rs index 33e4e31bec6..429a42a7252 100644 --- a/tests/rustdoc/attributes.rs +++ b/tests/rustdoc/attributes.rs @@ -9,6 +9,18 @@ pub extern "C" fn f() {} #[unsafe(export_name = "bar")] pub extern "C" fn g() {} +//@ has foo/fn.escape_special.html '//*[@class="code-attribute"]' \ +// '#[unsafe(export_name = "\n\"\n")]' +#[unsafe(export_name = "\n\" +")] +pub extern "C" fn escape_special() {} + +// issue: <https://github.com/rust-lang/rust/issues/142835> +//@ has foo/fn.escape_html.html '//*[@class="code-attribute"]' \ +// '#[unsafe(export_name = "<script>alert()</script>")]' +#[unsafe(export_name = "<script>alert()</script>")] +pub extern "C" fn escape_html() {} + //@ has foo/fn.example.html '//*[@class="code-attribute"]' '#[unsafe(link_section = ".text")]' #[unsafe(link_section = ".text")] pub extern "C" fn example() {} |
