From fd1a00db76a77b827246fad838d1bba3a214935f Mon Sep 17 00:00:00 2001
From: Alex Crichton <alex@alexcrichton.com>
Date: Thu, 27 Sep 2018 12:20:18 -0700
Subject: [PATCH] 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
---
 crates/test/src/rt/browser.rs | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/crates/test/src/rt/browser.rs b/crates/test/src/rt/browser.rs
index fc97d5ad..a3beecee 100644
--- a/crates/test/src/rt/browser.rs
+++ b/crates/test/src/rt/browser.rs
@@ -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);
     }