Skip to content

Commit

Permalink
Rollup merge of rust-lang#47855 - ollie27:rustdoc_hoedown_link_title,…
Browse files Browse the repository at this point in the history
… r=QuietMisdreavus

rustdoc: Fix link title rendering with hoedown

The link title needs to be HTML escaped.

It was broken by rust-lang#47046.

r? @QuietMisdreavus
  • Loading branch information
kennytm authored Jan 30, 2018
2 parents b83fb0f + ae98f4c commit 393a199
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ pub fn render(w: &mut fmt::Formatter,
let link_out = format!("<a href=\"{link}\"{title}>{content}</a>",
link = link_buf,
title = title.map_or(String::new(),
|t| format!(" title=\"{}\"", t)),
|t| format!(" title=\"{}\"", Escape(&t))),
content = content.unwrap_or(String::new()));

unsafe { hoedown_buffer_put(ob, link_out.as_ptr(), link_out.len()); }
Expand Down
19 changes: 19 additions & 0 deletions src/test/rustdoc/link-title-escape.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z unstable-options --disable-commonmark

#![crate_name = "foo"]

//! hello [foo]
//!
//! [foo]: url 'title & <stuff> & "things"'
// @has 'foo/index.html' 'title &amp; &lt;stuff&gt; &amp; &quot;things&quot;'

0 comments on commit 393a199

Please sign in to comment.