Fix tonumber and toboolean to reject strings with embedded null bytes (#3496)

This commit is contained in:
itchyny authored and GitHub committed 2026-03-05 08:28:43 +09:00
1 parent bfcf82fde1
commit ed3c7f214b
2 files changed
+17

No files matched your search

+9
View File
@@ -698,6 +698,10 @@ null
4
15
"123\u0000456" | try tonumber catch .
null
"string (\"123\\u0000456\") cannot be parsed as a number"
map(toboolean)
["false","true",false,true]
[false,true,false,true]
@@ -713,6 +717,11 @@ map(toboolean)
"array ([]) cannot be parsed as a boolean"
"object ({}) cannot be parsed as a boolean"
"true\u0000x", "false\u0000" | try toboolean catch .
null
"string (\"true\\u0000x\") cannot be parsed as a boolean"
"string (\"false\\u0000\") cannot be parsed as a boolean"
[{"a":42},.object,10,.num,false,true,null,"b",[1,4]] | .[] as $x | [$x == .[]]
{"object": {"a":42}, "num":10.0}
[true, true, false, false, false, false, false, false, false]