]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: Fix link title rendering with hoedown
authorOliver Middleton <olliemail27@gmail.com>
Mon, 29 Jan 2018 16:44:35 +0000 (16:44 +0000)
committerOliver Middleton <olliemail27@gmail.com>
Mon, 29 Jan 2018 19:26:31 +0000 (19:26 +0000)
The link title needs to be HTML escaped.

src/librustdoc/html/markdown.rs
src/test/rustdoc/link-title-escape.rs [new file with mode: 0644]

index dce0c4b001a0d94b86909027ca54a3fc0bc8b2f4..82ced00644da8ea09418af69b07c3fd81c12c9ab 100644 (file)
@@ -872,7 +872,7 @@ fn escape_href(ob: &mut String, s: &str) {
         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()); }
diff --git a/src/test/rustdoc/link-title-escape.rs b/src/test/rustdoc/link-title-escape.rs
new file mode 100644 (file)
index 0000000..eb53c3c
--- /dev/null
@@ -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;'