mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-01 18:01:06 +00: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 {
|
impl super::Formatter for Browser {
|
||||||
fn writeln(&self, line: &str) {
|
fn writeln(&self, line: &str) {
|
||||||
let mut html = self.pre.inner_html();
|
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");
|
html.push_str("\n");
|
||||||
self.pre.set_inner_html(&html);
|
self.pre.set_inner_html(&html);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user