File tree 3 files changed +19
-3
lines changed
3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ use rustc::hir;
26
26
use clean;
27
27
use core:: DocAccessLevels ;
28
28
use html:: item_type:: ItemType ;
29
+ use html:: escape:: Escape ;
29
30
use html:: render;
30
31
use html:: render:: { cache, CURRENT_LOCATION_KEY } ;
31
32
@@ -496,7 +497,7 @@ impl fmt::Display for clean::Type {
496
497
primitive_link ( f, clean:: PrimitiveType :: Array , "[" ) ?;
497
498
write ! ( f, "{}" , t) ?;
498
499
primitive_link ( f, clean:: PrimitiveType :: Array ,
499
- & format ! ( "; {}]" , * s ) )
500
+ & format ! ( "; {}]" , Escape ( s ) ) )
500
501
}
501
502
clean:: Bottom => f. write_str ( "!" ) ,
502
503
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> {
1866
1866
let Initializer ( s) = * self ;
1867
1867
if s. is_empty ( ) { return Ok ( ( ) ) ; }
1868
1868
write ! ( f, "<code> = </code>" ) ?;
1869
- write ! ( f, "<code>{}</code>" , s )
1869
+ write ! ( f, "<code>{}</code>" , Escape ( s ) )
1870
1870
}
1871
1871
}
1872
1872
@@ -2106,7 +2106,7 @@ fn assoc_const(w: &mut fmt::Formatter,
2106
2106
2107
2107
write ! ( w, ": {}" , ty) ?;
2108
2108
if let Some ( default) = default {
2109
- write ! ( w, " = {}" , default ) ?;
2109
+ write ! ( w, " = {}" , Escape ( default ) ) ?;
2110
2110
}
2111
2111
Ok ( ( ) )
2112
2112
}
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