aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/lua.txt
diff options
context:
space:
mode:
authorBartłomiej Maryńczak <marynczak.bartlomiej@gmail.com>2024-12-06 21:43:41 +0100
committerGitHub <noreply@github.com>2024-12-06 12:43:41 -0800
commit517ecb85f58ed6ac8b4d5443931612e75e7c7dc2 (patch)
treec98da87e669d073773762574d504ffb621fe20fa /runtime/doc/lua.txt
parentfac96b72a59e15d483e03bdc43b9ba08ce6c828e (diff)
downloadrneovim-517ecb85f58ed6ac8b4d5443931612e75e7c7dc2.tar.gz
rneovim-517ecb85f58ed6ac8b4d5443931612e75e7c7dc2.tar.bz2
rneovim-517ecb85f58ed6ac8b4d5443931612e75e7c7dc2.zip
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.)
Diffstat (limited to 'runtime/doc/lua.txt')
-rw-r--r--runtime/doc/lua.txt7
1 files changed, 5 insertions, 2 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 48fa595a53..80808abd51 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -811,11 +811,14 @@ vim.json.decode({str}, {opts}) *vim.json.decode()*
Return: ~
(`any`)
-vim.json.encode({obj}) *vim.json.encode()*
+vim.json.encode({obj}, {opts}) *vim.json.encode()*
Encodes (or "packs") Lua object {obj} as JSON in a Lua string.
Parameters: ~
- • {obj} (`any`)
+ • {obj} (`any`)
+ • {opts} (`table<string,any>?`) Options table with keys:
+ • escape_slash: (boolean) (default false) When true, escapes
+ `/` character in JSON strings
Return: ~
(`string`)