Skip to content

Commit 8bcbf91

Browse files
committed
Auto merge of #46326 - GuillaumeGomez:sidebar-text, r=QuietMisdreavus
Fix invalid HTML escape Fixes #46289. r? @QuietMisdreavus
2 parents c3942e7 + 35f5be6 commit 8bcbf91

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

src/librustdoc/html/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
601601
clean::Primitive(prim) => primitive_link(f, prim, prim.as_str()),
602602
clean::BareFunction(ref decl) => {
603603
if f.alternate() {
604-
write!(f, "{}{}fn{:#}{:#}",
604+
write!(f, "{}{:#}fn{:#}{:#}",
605605
UnsafetySpace(decl.unsafety),
606606
AbiSpace(decl.abi),
607607
decl.generics,

src/librustdoc/html/render.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,8 +2292,8 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
22922292
f.generics).len();
22932293
write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it)?)?;
22942294
render_attributes(w, it)?;
2295-
write!(w, "{vis}{constness}{unsafety}{abi}fn \
2296-
{name}{generics}{decl}{where_clause}</pre>",
2295+
write!(w,
2296+
"{vis}{constness}{unsafety}{abi}fn {name}{generics}{decl}{where_clause}</pre>",
22972297
vis = VisSpace(&it.visibility),
22982298
constness = ConstnessSpace(f.constness),
22992299
unsafety = UnsafetySpace(f.unsafety),
@@ -2302,9 +2302,9 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
23022302
generics = f.generics,
23032303
where_clause = WhereClause { gens: &f.generics, indent: 0, end_newline: true },
23042304
decl = Method {
2305-
decl: &f.decl,
2306-
name_len,
2307-
indent: 0,
2305+
decl: &f.decl,
2306+
name_len,
2307+
indent: 0,
23082308
})?;
23092309
document(w, cx, it)
23102310
}
@@ -3658,6 +3658,7 @@ fn small_url_encode(s: &str) -> String {
36583658
.replace(";", "%3B")
36593659
.replace("[", "%5B")
36603660
.replace("]", "%5D")
3661+
.replace("\"", "%22")
36613662
}
36623663

36633664
fn sidebar_assoc_items(it: &clean::Item) -> String {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name = "foo"]
12+
13+
// ignore-tidy-linelength
14+
15+
pub trait Foo<T> {
16+
fn foo() {}
17+
}
18+
19+
pub struct Bar;
20+
21+
// @has foo/struct.Bar.html
22+
// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Foo%3Cunsafe%20extern%20%22C%22%20fn()%3E"]' 'Foo<unsafe extern "C" fn()>'
23+
impl Foo<unsafe extern "C" fn()> for Bar {}

src/tools/linkchecker/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ fn small_url_encode(s: &str) -> String {
8181
.replace(";", "%3B")
8282
.replace("[", "%5B")
8383
.replace("]", "%5D")
84+
.replace("\"", "%22")
8485
}
8586

8687
impl FileEntry {

0 commit comments

Comments
 (0)