mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-26 03:24:13 +03:00
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:
parent
65fc8228f1
commit
fd1a00db76
@ -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("<"),
|
||||
'>' => html.push_str(">"),
|
||||
'&' => html.push_str("&"),
|
||||
c => html.push(c),
|
||||
}
|
||||
}
|
||||
html.push_str("\n");
|
||||
self.pre.set_inner_html(&html);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user