mirror of
https://github.com/mikefarah/yq.git
synced 2026-03-10 15:54:26 +00:00
Fixing parsing of escaped characters #2506
This commit is contained in:
parent
389486829d
commit
e49e588ab5
@ -381,6 +381,12 @@ func stringValue() yqAction {
|
||||
log.Debug("unwrapped: %v", value)
|
||||
value = strings.ReplaceAll(value, "\\\"", "\"")
|
||||
value = strings.ReplaceAll(value, "\\n", "\n")
|
||||
value = strings.ReplaceAll(value, "\\t", "\t")
|
||||
value = strings.ReplaceAll(value, "\\r", "\r")
|
||||
value = strings.ReplaceAll(value, "\\f", "\f")
|
||||
value = strings.ReplaceAll(value, "\\v", "\v")
|
||||
value = strings.ReplaceAll(value, "\\b", "\b")
|
||||
value = strings.ReplaceAll(value, "\\a", "\a")
|
||||
log.Debug("replaced: %v", value)
|
||||
return &token{TokenType: operationToken, Operation: &Operation{
|
||||
OperationType: stringInterpolationOpType,
|
||||
|
||||
@ -704,6 +704,90 @@ var participleLexerScenarios = []participleLexerScenario{
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
expression: `"string with a\r"`,
|
||||
tokens: []*token{
|
||||
{
|
||||
TokenType: operationToken,
|
||||
Operation: &Operation{
|
||||
OperationType: stringInterpolationOpType,
|
||||
Value: "string with a\r",
|
||||
StringValue: "string with a\r",
|
||||
Preferences: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
expression: `"string with a\t"`,
|
||||
tokens: []*token{
|
||||
{
|
||||
TokenType: operationToken,
|
||||
Operation: &Operation{
|
||||
OperationType: stringInterpolationOpType,
|
||||
Value: "string with a\t",
|
||||
StringValue: "string with a\t",
|
||||
Preferences: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
expression: `"string with a\f"`,
|
||||
tokens: []*token{
|
||||
{
|
||||
TokenType: operationToken,
|
||||
Operation: &Operation{
|
||||
OperationType: stringInterpolationOpType,
|
||||
Value: "string with a\f",
|
||||
StringValue: "string with a\f",
|
||||
Preferences: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
expression: `"string with a\v"`,
|
||||
tokens: []*token{
|
||||
{
|
||||
TokenType: operationToken,
|
||||
Operation: &Operation{
|
||||
OperationType: stringInterpolationOpType,
|
||||
Value: "string with a\v",
|
||||
StringValue: "string with a\v",
|
||||
Preferences: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
expression: `"string with a\b"`,
|
||||
tokens: []*token{
|
||||
{
|
||||
TokenType: operationToken,
|
||||
Operation: &Operation{
|
||||
OperationType: stringInterpolationOpType,
|
||||
Value: "string with a\b",
|
||||
StringValue: "string with a\b",
|
||||
Preferences: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
expression: `"string with a\a"`,
|
||||
tokens: []*token{
|
||||
{
|
||||
TokenType: operationToken,
|
||||
Operation: &Operation{
|
||||
OperationType: stringInterpolationOpType,
|
||||
Value: "string with a\a",
|
||||
StringValue: "string with a\a",
|
||||
Preferences: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestParticipleLexer(t *testing.T) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user