From 5d674288571c9801c253e913d8d49c8e79230d40 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 18 Jun 2017 09:48:52 -0400 Subject: [PATCH] Allow more chars in unquoted text formatter output --- text_formatter.go | 2 +- text_formatter_test.go | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/text_formatter.go b/text_formatter.go index ba88854..6821fcb 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -153,7 +153,7 @@ func (f *TextFormatter) needsQuoting(text string) bool { if !((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || - ch == '-' || ch == '.') { + ch == '-' || ch == '.' || ch == '_' || ch == '/' || ch == '@' || ch == '^' || ch == '+') { return true } } diff --git a/text_formatter_test.go b/text_formatter_test.go index 9793b5f..08571db 100644 --- a/text_formatter_test.go +++ b/text_formatter_test.go @@ -28,7 +28,13 @@ func TestQuoting(t *testing.T) { checkQuoting(false, "abcd") checkQuoting(false, "v1.0") checkQuoting(false, "1234567890") - checkQuoting(true, "/foobar") + checkQuoting(false, "/foobar") + checkQuoting(false, "foo_bar") + checkQuoting(false, "foo@bar") + checkQuoting(false, "foobar^") + checkQuoting(false, "+/-_^@f.oobar") + checkQuoting(true, "foobar$") + checkQuoting(true, "&foobar") checkQuoting(true, "x y") checkQuoting(true, "x,y") checkQuoting(false, errors.New("invalid")) @@ -38,7 +44,12 @@ func TestQuoting(t *testing.T) { tf.QuoteCharacter = "`" checkQuoting(false, "") checkQuoting(false, "abcd") - checkQuoting(true, "/foobar") + checkQuoting(false, "/foobar") + checkQuoting(false, "foo_bar") + checkQuoting(false, "foo@bar") + checkQuoting(false, "foobar^") + checkQuoting(true, "foobar$") + checkQuoting(true, "&foobar") checkQuoting(true, errors.New("invalid argument")) // Test for multi-character quotes.