Skip to content

Commit

Permalink
Escape some rustdoc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nagisa committed Feb 20, 2015
1 parent 522d09d commit d99af37
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/librustdoc/html/format.rs
Expand Up @@ -25,6 +25,7 @@ use clean;
use stability_summary::ModuleSummary;
use html::item_type::ItemType;
use html::render;
use html::escape::Escape;
use html::render::{cache, CURRENT_LOCATION_KEY};

/// Helper to render an optional visibility with a space after it (if the
Expand Down Expand Up @@ -710,13 +711,14 @@ impl<'a> fmt::Display for Stability<'a> {
let Stability(stab) = *self;
match *stab {
Some(ref stability) => {
let lvl = if stability.deprecated_since.is_empty() {
format!("{}", stability.level)
} else {
"Deprecated".to_string()
};
write!(f, "<a class='stability {lvl}' title='{reason}'>{lvl}</a>",
lvl = if stability.deprecated_since.is_empty() {
format!("{}", stability.level)
} else {
"Deprecated".to_string()
},
reason = stability.reason)
lvl = Escape(&*lvl),
reason = Escape(&*stability.reason))
}
None => Ok(())
}
Expand All @@ -728,14 +730,15 @@ impl<'a> fmt::Display for ConciseStability<'a> {
let ConciseStability(stab) = *self;
match *stab {
Some(ref stability) => {
let lvl = if stability.deprecated_since.is_empty() {
format!("{}", stability.level)
} else {
"Deprecated".to_string()
};
write!(f, "<a class='stability {lvl}' title='{lvl}{colon}{reason}'></a>",
lvl = if stability.deprecated_since.is_empty() {
format!("{}", stability.level)
} else {
"Deprecated".to_string()
},
lvl = Escape(&*lvl),
colon = if stability.reason.len() > 0 { ": " } else { "" },
reason = stability.reason)
reason = Escape(&*stability.reason))
}
None => {
write!(f, "<a class='stability Unmarked' title='No stability level'></a>")
Expand Down

0 comments on commit d99af37

Please sign in to comment.