Merge pull request #900 from alexcrichton/fix-test

Escape HTML text in browser failure messages
This commit is contained in:
Alex Crichton 2018-09-27 13:50:53 -07:00 committed by GitHub
commit 69ec889dc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 30 deletions

View File

@ -1,29 +0,0 @@
rustc \
+nightly \
--crate-name \
wasm_bindgen_test_runner \
crates/test-runner/src/main.rs \
--crate-type \
bin \
--emit=dep-info,link \
-C \
opt-level=s \
-C \
panic=abort \
-C \
lto \
-C \
metadata=de5c24b259631256 \
-C \
extra-filename=-de5c24b259631256 \
--out-dir \
/home/alex/code/wasm-bindgen/target/release/deps \
-L \
dependency=/home/alex/code/wasm-bindgen/target/release/deps \
--extern \
failure=/home/alex/code/wasm-bindgen/target/release/deps/libfailure-7c7642ad9a5ea78f.rlib \
--extern \
wasm_bindgen_cli_support=/home/alex/code/wasm-bindgen/target/release/deps/libwasm_bindgen_cli_support-319f8cb472c7d7e6.rlib \
-L \
native=/home/alex/code/wasm-bindgen/target/release/build/backtrace-sys-219bc8940e273b6b/out \
-Z time-passes

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);
}