File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ use rustc::hir;
2626use clean;
2727use core:: DocAccessLevels ;
2828use html:: item_type:: ItemType ;
29+ use html:: escape:: Escape ;
2930use html:: render;
3031use html:: render:: { cache, CURRENT_LOCATION_KEY } ;
3132
@@ -496,7 +497,7 @@ impl fmt::Display for clean::Type {
496497 primitive_link ( f, clean:: PrimitiveType :: Array , "[" ) ?;
497498 write ! ( f, "{}" , t) ?;
498499 primitive_link ( f, clean:: PrimitiveType :: Array ,
499- & format ! ( "; {}]" , * s ) )
500+ & format ! ( "; {}]" , Escape ( s ) ) )
500501 }
501502 clean:: Bottom => f. write_str ( "!" ) ,
502503 clean:: RawPointer ( m, ref t) => {
Original file line number Diff line number Diff line change @@ -1866,7 +1866,7 @@ impl<'a> fmt::Display for Initializer<'a> {
18661866 let Initializer ( s) = * self ;
18671867 if s. is_empty ( ) { return Ok ( ( ) ) ; }
18681868 write ! ( f, "<code> = </code>" ) ?;
1869- write ! ( f, "<code>{}</code>" , s )
1869+ write ! ( f, "<code>{}</code>" , Escape ( s ) )
18701870 }
18711871}
18721872
@@ -2106,7 +2106,7 @@ fn assoc_const(w: &mut fmt::Formatter,
21062106
21072107 write ! ( w, ": {}" , ty) ?;
21082108 if let Some ( default) = default {
2109- write ! ( w, " = {}" , default ) ?;
2109+ write ! ( w, " = {}" , Escape ( default ) ) ?;
21102110 }
21112111 Ok ( ( ) )
21122112}
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ // Test that we HTML-escape Rust expressions, where HTML special chars
12+ // can occur, and we know it's definitely not markup.
13+
14+ // @has escape_rust_expr/constant.CONST_S.html '//pre[@class="rust const"]' '"<script>"'
15+ pub const CONST_S : & ' static str = "<script>" ;
You can’t perform that action at this time.
0 commit comments