From ad6206078fff5efd41c7d953ff1227a66655846e Mon Sep 17 00:00:00 2001 From: Ben Tranter Date: Mon, 12 Sep 2016 11:03:19 -0400 Subject: [PATCH] Fix non-ASCII quotes in HTML Fixes #304 Changes the non-ASCII curly quotes in the HTML to use the regular ASCII double quotes. Also adds a test to check for the existence of non-ASCII characters in that same HTML. --- server/monitor.go | 2 +- server/monitor_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/server/monitor.go b/server/monitor.go index f4b36da9..6cce144b 100644 --- a/server/monitor.go +++ b/server/monitor.go @@ -442,7 +442,7 @@ func (s *Server) HandleRoot(w http.ResponseWriter, r *http.Request) { diff --git a/server/monitor_test.go b/server/monitor_test.go index b6cf2122..6a5a4725 100644 --- a/server/monitor_test.go +++ b/server/monitor_test.go @@ -11,6 +11,7 @@ import ( "strings" "testing" "time" + "unicode" "github.com/nats-io/nats" "sync" @@ -1167,6 +1168,17 @@ func TestHandleRoot(t *testing.T) { if resp.StatusCode != 200 { t.Fatalf("Expected a 200 response, got %d\n", resp.StatusCode) } + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + t.Fatalf("Expected no error reading body: Got %v\n", err) + } + for _, b := range body { + if b > unicode.MaxASCII { + t.Fatalf("Expected body to contain only ASCII characters, but got %v\n", b) + } + } + ct := resp.Header.Get("Content-Type") if !strings.Contains(ct, "text/html") { t.Fatalf("Expected text/html response, got %s\n", ct)