Vladimir Davydov
authored
This commit adds the json_escape_forward_slash variable and a tweak for it that is now used by the compat module. The new variable configures whether '/' is escaped when encoded in JSON. Note, the old implementation was quite messy so we had to rework it: - Drop luaL_serializer::encode_escape_forward_slash. This was an undocumented serializer option implemented only by the JSON serializer and used only by the compat module. Now, we use the json_escape_forward_slash global tweak for all JSON serializers instead, because making this tweak configurable per serializer doesn't make much sense. - Don't use mp_char2escape for escaping JSON characters. Historically, we used this table defined in libmsgpuck in the json_escape utility function. It equals the escape table used by the JSON encoder so it looks more reasonable to use the JSON encoder escape table in json_escape. This commit moves the JSON encoder escape table to util.c and adds an inline utility function json_escape_char which is now used by the JSON encoder and json_escape. - Drop an extra JSON escape table with '/' escaped. We had two escape tables in JSON, one with escaped '/' and another with unescaped '/'. Duplicating tables like this is error-prone and ugly. Let's use one table with '/' unescaped and check the json_escape_forward_slash flag in json_escape_char instead. The cost of this check is negligible performance-wise. This commit also drops the lua/compat.c source file, because it isn't used anymore. While we are at it, remove any mentions of MsgPack from the changelog entry for the json_escape_forward_slash compat option, because it isn't relevant anymore. Closes #8117 NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
Name | Last commit | Last update |
---|---|---|
.. | ||
LICENSE | ||
lua_cjson.c | ||
lua_cjson.h | ||
strbuf.c | ||
strbuf.h |