app: raise an error on too nested tables serialization
Closes #4434 Follow-up #4366 @TarantoolBot document Title: json/msgpack.cfg.encode_deep_as_nil option Tarantool has several so called serializers to convert data between Lua and another format: YAML, JSON, msgpack. YAML is a crazy serializer without depth restrictions. But for JSON, msgpack, and msgpackffi a user could set encode_max_depth option. That option led to crop of a table when it had too many nested levels. Sometimes such behaviour is undesirable. Now an error is raised instead of data corruption: t = nil for i = 1, 100 do t = {t} end msgpack.encode(t) -- Here an exception is thrown. To disable it and return the old behaviour back here is a new option: <serializer>.cfg({encode_deep_as_nil = true}) Option encode_deep_as_nil works for JSON, msgpack, and msgpackffi modules, and is false by default. It means, that now if some existing users have cropping, even intentional, they will get the exception. (cherry picked from commit d7a8942a)
Showing
- src/lua/msgpack.c 8 additions, 0 deletionssrc/lua/msgpack.c
- src/lua/msgpackffi.lua 4 additions, 0 deletionssrc/lua/msgpackffi.lua
- src/lua/utils.c 1 addition, 0 deletionssrc/lua/utils.c
- src/lua/utils.h 7 additions, 0 deletionssrc/lua/utils.h
- test/app-tap/json.test.lua 4 additions, 2 deletionstest/app-tap/json.test.lua
- test/app-tap/lua/serializer_test.lua 20 additions, 1 deletiontest/app-tap/lua/serializer_test.lua
- test/app-tap/msgpackffi.test.lua 9 additions, 2 deletionstest/app-tap/msgpackffi.test.lua
- test/box/tuple.result 7 additions, 1 deletiontest/box/tuple.result
- test/box/tuple.test.lua 3 additions, 1 deletiontest/box/tuple.test.lua
- third_party/lua-cjson/lua_cjson.c 8 additions, 2 deletionsthird_party/lua-cjson/lua_cjson.c
Loading
Please register or sign in to comment