mirror of
https://github.com/google/go-jsonnet.git
synced 2026-05-05 20:16:12 +02:00
add non-negative check in second parameter for subStr
This commit is contained in:
parent
f0a060e259
commit
9e9321f69a
@ -991,6 +991,11 @@ func builtinSubstr(i *interpreter, inputStr, inputFrom, inputLen value) (value,
|
||||
return nil, makeRuntimeError(msg, i.getCurrentStackTrace())
|
||||
}
|
||||
|
||||
if fromV.value < 0 {
|
||||
msg := fmt.Sprintf("substr second parameter should be greater than zero, got %f", fromV.value)
|
||||
return nil, makeRuntimeError(msg, i.getCurrentStackTrace())
|
||||
}
|
||||
|
||||
lenV, err := i.getNumber(inputLen)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("substr third parameter should be a number, got %s", inputLen.getType().name)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user