Remove backslash from quoted strings
parent
fb56ab9a06
commit
adea3c38be
|
@ -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)
|
err = fmt.Errorf("unexpected end of input, quote started at position %d", start)
|
||||||
return
|
return
|
||||||
} else if r == quote && prev != '\\' {
|
} 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
|
p.pos += w
|
||||||
|
|
||||||
// Advance until section end (after "," or ";")
|
// Advance until section end (after "," or ";")
|
||||||
|
|
|
@ -67,7 +67,7 @@ func TestParseActions(t *testing.T) {
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Equal(t, 1, len(actions))
|
require.Equal(t, 1, len(actions))
|
||||||
require.Equal(t, "http", actions[0].Action)
|
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)
|
require.Equal(t, `http://example.com`, actions[0].URL)
|
||||||
|
|
||||||
// Single quotes
|
// Single quotes
|
||||||
|
@ -75,7 +75,7 @@ func TestParseActions(t *testing.T) {
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Equal(t, 1, len(actions))
|
require.Equal(t, 1, len(actions))
|
||||||
require.Equal(t, "http", actions[0].Action)
|
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)
|
require.Equal(t, `http://example.com`, actions[0].URL)
|
||||||
|
|
||||||
// Single quotes (JSON)
|
// Single quotes (JSON)
|
||||||
|
|
Loading…
Reference in New Issue