Skip to content

Commit 36e58ea

Browse files
authoredJan 18, 2020
Rollup merge of #68224 - GuillaumeGomez:prevent-urls-in-headings, r=ollie27
Prevent urls in headings Fixes #68215. cc @pietroalbini @ollie27 r? @kinnison
2 parents 733c7f4 + 298e8ad commit 36e58ea

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed
 

‎src/librustdoc/html/markdown.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,10 @@ impl<'a, 'b, 'ids, I: Iterator<Item = Event<'a>>> Iterator for HeadingLinks<'a,
380380
}
381381
_ => {}
382382
}
383-
self.buf.push_back(event);
383+
match event {
384+
Event::Start(Tag::Link(_, _, _)) | Event::End(Tag::Link(..)) => {}
385+
event => self.buf.push_back(event),
386+
}
384387
}
385388
let id = self.id_map.derive(id);
386389

@@ -395,7 +398,7 @@ impl<'a, 'b, 'ids, I: Iterator<Item = Event<'a>>> Iterator for HeadingLinks<'a,
395398

396399
let start_tags = format!(
397400
"<h{level} id=\"{id}\" class=\"section-header\">\
398-
<a href=\"#{id}\">",
401+
<a href=\"#{id}\">",
399402
id = id,
400403
level = level
401404
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![crate_name = "foo"]
2+
3+
// @has foo/fn.foo.html
4+
// !@has - '//a[@href="http://a.a"]'
5+
// @has - '//a[@href="#implementing-stuff-somewhere"]' 'Implementing stuff somewhere'
6+
// @has - '//a[@href="#another-one-urg"]' 'Another one urg'
7+
8+
/// fooo
9+
///
10+
/// # Implementing [stuff](http://a.a "title") somewhere
11+
///
12+
/// hello
13+
///
14+
/// # Another [one][two] urg
15+
///
16+
/// [two]: http://a.a
17+
pub fn foo() {}

0 commit comments

Comments
 (0)