jsonata-js / jsonata

JSONata query and transformation language - http://jsonata.org
MIT License
2.05k stars 220 forks source link

$pad Function With Non-Integer Width Results in Uncaught RangeError #717

Open melalawi opened 1 day ago

melalawi commented 1 day ago

Hello,

Attempting to invoke $pad with a decimal value length like 2.1 results in RangeError: invalid array length being thrown. This is due to the padding array being instantiated with a non-integer length which is not allowed. This exception is not caught anywhere in the call stack.

We should either floor width before using it to calculate padLength or throw a JSONata exception.

Repro: $pad("s", 2.1, " ")