diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2015-02-20 15:59:51 +0200 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2015-02-20 15:59:51 +0200 |
| commit | d99af375d302fe47c5f02125634995e0d930f4ff (patch) | |
| tree | 06adb94e34682d3aef255991229720a7b0969b87 /src/librustdoc/html/format.rs | |
| parent | 522d09dfecbeca1595f25ac58c6d0178bbd21d7d (diff) | |
| download | rust-d99af375d302fe47c5f02125634995e0d930f4ff.tar.gz rust-d99af375d302fe47c5f02125634995e0d930f4ff.zip | |
Escape some rustdoc strings
Diffstat (limited to 'src/librustdoc/html/format.rs')
| -rw-r--r-- | src/librustdoc/html/format.rs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index ed7f051408c..11d9ecac14d 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -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 @@ -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(()) } @@ -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>") |
