mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22: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 {
|
if inExpression {
|
||||||
return "", fmt.Errorf("unclosed interpolation string \\(")
|
log.Warning("unclosed interpolation string, skipping interpolation")
|
||||||
|
return str, nil
|
||||||
}
|
}
|
||||||
return sb.String(), nil
|
return sb.String(), nil
|
||||||
}
|
}
|
||||||
|
@ -66,18 +66,22 @@ var stringsOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
description: "Interpolation - unclosed interpolation string",
|
description: "Interpolation - unclosed interpolation string",
|
||||||
document: `value: things`,
|
document: `value: things`,
|
||||||
expression: `"Hi \("`,
|
expression: `"Hi \("`,
|
||||||
expectedError: "unclosed interpolation string \\(",
|
expected: []string{
|
||||||
|
"D0, P[], (!!str)::Hi \\(\n",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
description: "Interpolation - unclosed interpolation string due to escape",
|
description: "Interpolation - unclosed interpolation string due to escape",
|
||||||
document: `value: things`,
|
document: `value: things`,
|
||||||
expression: `"Hi \(\)"`,
|
expression: `"Hi \(\)"`,
|
||||||
expectedError: "unclosed interpolation string \\(",
|
expected: []string{
|
||||||
|
"D0, P[], (!!str)::Hi \\(\\)\n",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "To up (upper) case",
|
description: "To up (upper) case",
|
||||||
|
Loading…
Reference in New Issue
Block a user