From adea3c38bedd184c49e42c6630cb50921f870d20 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Wed, 27 Apr 2022 13:56:21 -0400 Subject: [PATCH] Remove backslash from quoted strings --- server/actions.go | 2 +- server/actions_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/actions.go b/server/actions.go index 320c79cd..7ddbf414 100644 --- a/server/actions.go +++ b/server/actions.go @@ -251,7 +251,7 @@ func (p *actionParser) parseQuotedValue(quote rune) (value string, last bool, er err = fmt.Errorf("unexpected end of input, quote started at position %d", start) return } else if r == quote && prev != '\\' { - value = p.input[start:p.pos] + value = strings.ReplaceAll(p.input[start:p.pos], "\\"+string(quote), string(quote)) // \" -> " p.pos += w // Advance until section end (after "," or ";") diff --git a/server/actions_test.go b/server/actions_test.go index 4f16bea0..2414a1ff 100644 --- a/server/actions_test.go +++ b/server/actions_test.go @@ -67,7 +67,7 @@ func TestParseActions(t *testing.T) { require.Nil(t, err) require.Equal(t, 1, len(actions)) require.Equal(t, "http", actions[0].Action) - require.Equal(t, `Look ma, \"quotes\"; and semicolons`, actions[0].Label) + require.Equal(t, `Look ma, "quotes"; and semicolons`, actions[0].Label) require.Equal(t, `http://example.com`, actions[0].URL) // Single quotes @@ -75,7 +75,7 @@ func TestParseActions(t *testing.T) { require.Nil(t, err) require.Equal(t, 1, len(actions)) require.Equal(t, "http", actions[0].Action) - require.Equal(t, `"quotes" and \'single quotes\'`, actions[0].Label) + require.Equal(t, `"quotes" and 'single quotes'`, actions[0].Label) require.Equal(t, `http://example.com`, actions[0].URL) // Single quotes (JSON)