From f78f8d07f6aca1903611d049bf064c8cea107d9d Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Mon, 24 Apr 2017 19:27:50 +0200 Subject: [PATCH] Safely format data when printing Fixes #531 --- text_formatter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/text_formatter.go b/text_formatter.go index ba88854..8006c0d 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -174,14 +174,14 @@ func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) { if !f.needsQuoting(value) { b.WriteString(value) } else { - fmt.Fprintf(b, "%s%v%s", f.QuoteCharacter, value, f.QuoteCharacter) + fmt.Fprintf(b, "%q", value) } case error: errmsg := value.Error() if !f.needsQuoting(errmsg) { b.WriteString(errmsg) } else { - fmt.Fprintf(b, "%s%v%s", f.QuoteCharacter, errmsg, f.QuoteCharacter) + fmt.Fprintf(b, "%q", errmsg) } default: fmt.Fprint(b, value)