Skip and warn when interpolating strings and theres a unclosed bracket #2083

This commit is contained in:
Mike Farah 2024-06-29 15:20:07 +10:00
parent 0b7d4b799c
commit 28646c7b50
2 changed files with 16 additions and 11 deletions

View File

@ -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
}

View File

@ -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",