@@ -25,6 +25,7 @@ use clean;
25
25
use stability_summary:: ModuleSummary ;
26
26
use html:: item_type:: ItemType ;
27
27
use html:: render;
28
+ use html:: escape:: Escape ;
28
29
use html:: render:: { cache, CURRENT_LOCATION_KEY } ;
29
30
30
31
/// Helper to render an optional visibility with a space after it (if the
@@ -710,13 +711,14 @@ impl<'a> fmt::Display for Stability<'a> {
710
711
let Stability ( stab) = * self ;
711
712
match * stab {
712
713
Some ( ref stability) => {
714
+ let lvl = if stability. deprecated_since . is_empty ( ) {
715
+ format ! ( "{}" , stability. level)
716
+ } else {
717
+ "Deprecated" . to_string ( )
718
+ } ;
713
719
write ! ( f, "<a class='stability {lvl}' title='{reason}'>{lvl}</a>" ,
714
- lvl = if stability. deprecated_since. is_empty( ) {
715
- format!( "{}" , stability. level)
716
- } else {
717
- "Deprecated" . to_string( )
718
- } ,
719
- reason = stability. reason)
720
+ lvl = Escape ( & * lvl) ,
721
+ reason = Escape ( & * stability. reason) )
720
722
}
721
723
None => Ok ( ( ) )
722
724
}
@@ -728,14 +730,15 @@ impl<'a> fmt::Display for ConciseStability<'a> {
728
730
let ConciseStability ( stab) = * self ;
729
731
match * stab {
730
732
Some ( ref stability) => {
733
+ let lvl = if stability. deprecated_since . is_empty ( ) {
734
+ format ! ( "{}" , stability. level)
735
+ } else {
736
+ "Deprecated" . to_string ( )
737
+ } ;
731
738
write ! ( f, "<a class='stability {lvl}' title='{lvl}{colon}{reason}'></a>" ,
732
- lvl = if stability. deprecated_since. is_empty( ) {
733
- format!( "{}" , stability. level)
734
- } else {
735
- "Deprecated" . to_string( )
736
- } ,
739
+ lvl = Escape ( & * lvl) ,
737
740
colon = if stability. reason. len( ) > 0 { ": " } else { "" } ,
738
- reason = stability. reason)
741
+ reason = Escape ( & * stability. reason) )
739
742
}
740
743
None => {
741
744
write ! ( f, "<a class='stability Unmarked' title='No stability level'></a>" )
0 commit comments