Rollup merge of #68224 - GuillaumeGomez:prevent-urls-in-headings, r=ollie27

Prevent urls in headings

Fixes #68215.

cc @pietroalbini @ollie27

r? @kinnison
This commit is contained in:
Mazdak Farrokhzad 2020-01-18 19:36:03 +01:00 committed by GitHub
commit 36e58ea6bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -380,7 +380,10 @@ impl<'a, 'b, 'ids, I: Iterator<Item = Event<'a>>> Iterator for HeadingLinks<'a,
}
_ => {}
}
self.buf.push_back(event);
match event {
Event::Start(Tag::Link(_, _, _)) | Event::End(Tag::Link(..)) => {}
event => self.buf.push_back(event),
}
}
let id = self.id_map.derive(id);
@ -395,7 +398,7 @@ impl<'a, 'b, 'ids, I: Iterator<Item = Event<'a>>> Iterator for HeadingLinks<'a,
let start_tags = format!(
"<h{level} id=\"{id}\" class=\"section-header\">\
<a href=\"#{id}\">",
<a href=\"#{id}\">",
id = id,
level = level
);

View File

@ -0,0 +1,17 @@
#![crate_name = "foo"]
// @has foo/fn.foo.html
// !@has - '//a[@href="http://a.a"]'
// @has - '//a[@href="#implementing-stuff-somewhere"]' 'Implementing stuff somewhere'
// @has - '//a[@href="#another-one-urg"]' 'Another one urg'
/// fooo
///
/// # Implementing [stuff](http://a.a "title") somewhere
///
/// hello
///
/// # Another [one][two] urg
///
/// [two]: http://a.a
pub fn foo() {}