Escape HTML text in browser failure messages

When browser tests fail we're appending to `innerHTML`, which means that
we need to escape some characters for all to show up!

Closes #898
This commit is contained in:
Alex Crichton 2018-09-27 12:20:18 -07:00
parent 65fc8228f1
commit fd1a00db76

View File

@ -45,7 +45,14 @@ impl Browser {
impl super::Formatter for Browser {
fn writeln(&self, line: &str) {
let mut html = self.pre.inner_html();
html.push_str(&line);
for c in line.chars() {
match c {
'<' => html.push_str("&lt;"),
'>' => html.push_str("&gt;"),
'&' => html.push_str("&amp;"),
c => html.push(c),
}
}
html.push_str("\n");
self.pre.set_inner_html(&html);
}