Skip to content

Commit 1bf9f69

Browse files
Prevent urls in headings
1 parent bf84eb5 commit 1bf9f69

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/librustdoc/html/markdown.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,11 @@ 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(_, _, text)) => self.buf.push_back(Event::Text(text)),
385+
Event::End(Tag::Link(..)) => {}
386+
event => self.buf.push_back(event),
387+
}
384388
}
385389
let id = self.id_map.derive(id);
386390

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

396400
let start_tags = format!(
397401
"<h{level} id=\"{id}\" class=\"section-header\">\
398-
<a href=\"#{id}\">",
402+
<a href=\"#{id}\">",
399403
id = id,
400404
level = level
401405
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
7+
/// fooo
8+
///
9+
/// # Implementing [stuff](http://a.a) somewhere
10+
///
11+
/// hello
12+
pub fn foo() {}

0 commit comments

Comments
 (0)