From ab247a4b51df63ae97b609180960d558adb3cc31 Mon Sep 17 00:00:00 2001 From: Vasily Romanov Date: Tue, 14 Jun 2016 17:22:41 +0300 Subject: [PATCH] escape lt, gt --- jwriter/writer.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jwriter/writer.go b/jwriter/writer.go index b0856ba..85fa440 100644 --- a/jwriter/writer.go +++ b/jwriter/writer.go @@ -10,8 +10,9 @@ import ( // Writer is a JSON writer. type Writer struct { - Error error - Buffer buffer.Buffer + EscapeLtGt bool + Error error + Buffer buffer.Buffer } // Size returns the size of the data that was written out. @@ -224,6 +225,10 @@ func (w *Writer) String(s string) { escape = '\\' case '"': escape = '"' + case '<', '>': + if !w.EscapeLtGt { + continue + } default: if c >= 0x20 { // no escaping is required