mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +00:00
feat(stdlib): vim.json.encode(...,{escape_slash:boolean}) #30561
Problem: vim.json.encode escapes every slash in string values (for example in file paths), and is not optional. Use-case is for preventing HTML injections (eg. injecting `</script>` closing tag); in the context of Nvim this is rarely useful. Solution: - Add a `escape_slash` flag to `vim.json.encode`. - Defaults to `false`. (This is a "breaking" change, but more like a bug fix.)
This commit is contained in:
committed by
GitHub
parent
fac96b72a5
commit
517ecb85f5
@@ -35,5 +35,8 @@ function vim.json.decode(str, opts) end
|
||||
|
||||
--- Encodes (or "packs") Lua object {obj} as JSON in a Lua string.
|
||||
---@param obj any
|
||||
---@param opts? table<string,any> Options table with keys:
|
||||
--- - escape_slash: (boolean) (default false) When true, escapes `/`
|
||||
--- character in JSON strings
|
||||
---@return string
|
||||
function vim.json.encode(obj) end
|
||||
function vim.json.encode(obj, opts) end
|
||||
|
||||
Reference in New Issue
Block a user