mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-14 09:05:19 +02:00
Don't print whole json data buffer to errorstream on error
`errorstream` must not be overly verbose as clientside it is directly printed onto the ingame chat window. These days, the serverlist can contain > 200k bytes, so better print it to warningstream if the data buffer is too long.
This commit is contained in:
@@ -161,8 +161,14 @@ int ModApiUtil::l_parse_json(lua_State *L)
|
||||
if (!reader.parse(stream, root)) {
|
||||
errorstream << "Failed to parse json data "
|
||||
<< reader.getFormattedErrorMessages();
|
||||
errorstream << "data: \"" << jsonstr << "\""
|
||||
<< std::endl;
|
||||
size_t jlen = strlen(jsonstr);
|
||||
if (jlen > 100) {
|
||||
errorstream << "Data (" << jlen
|
||||
<< " bytes) printed to warningstream." << std::endl;
|
||||
warningstream << "data: \"" << jsonstr << "\"" << std::endl;
|
||||
} else {
|
||||
errorstream << "data: \"" << jsonstr << "\"" << std::endl;
|
||||
}
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user