diff --git a/pkg/yqlib/lexer_participle.go b/pkg/yqlib/lexer_participle.go index 958ae747..f62e6834 100644 --- a/pkg/yqlib/lexer_participle.go +++ b/pkg/yqlib/lexer_participle.go @@ -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, diff --git a/pkg/yqlib/lexer_participle_test.go b/pkg/yqlib/lexer_participle_test.go index ba3537f9..0b154d52 100644 --- a/pkg/yqlib/lexer_participle_test.go +++ b/pkg/yqlib/lexer_participle_test.go @@ -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) {