mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 05:38:04 +00:00
Skip and warn when interpolating strings and theres a unclosed bracket #2083
This commit is contained in:
parent
0b7d4b799c
commit
28646c7b50
@ -102,7 +102,8 @@ func interpolate(d *dataTreeNavigator, context Context, str string) (string, err
|
||||
}
|
||||
}
|
||||
if inExpression {
|
||||
return "", fmt.Errorf("unclosed interpolation string \\(")
|
||||
log.Warning("unclosed interpolation string, skipping interpolation")
|
||||
return str, nil
|
||||
}
|
||||
return sb.String(), nil
|
||||
}
|
||||
|
@ -66,18 +66,22 @@ var stringsOperatorScenarios = []expressionScenario{
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
description: "Interpolation - unclosed interpolation string",
|
||||
document: `value: things`,
|
||||
expression: `"Hi \("`,
|
||||
expectedError: "unclosed interpolation string \\(",
|
||||
skipDoc: true,
|
||||
description: "Interpolation - unclosed interpolation string",
|
||||
document: `value: things`,
|
||||
expression: `"Hi \("`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!str)::Hi \\(\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
description: "Interpolation - unclosed interpolation string due to escape",
|
||||
document: `value: things`,
|
||||
expression: `"Hi \(\)"`,
|
||||
expectedError: "unclosed interpolation string \\(",
|
||||
skipDoc: true,
|
||||
description: "Interpolation - unclosed interpolation string due to escape",
|
||||
document: `value: things`,
|
||||
expression: `"Hi \(\)"`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!str)::Hi \\(\\)\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "To up (upper) case",
|
||||
|
Loading…
Reference in New Issue
Block a user