aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
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
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')
-rw-r--r--runtime/doc/lua.txt7
-rw-r--r--runtime/doc/news.txt2
2 files changed, 7 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`)
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 8b4b396a26..3a3e1a8d64 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -60,6 +60,7 @@ DEFAULTS
current buffer, respectively.
• 'number', 'relativenumber', 'signcolumn', and 'foldcolumn' are disabled in
|terminal| buffers. See |terminal-config| for an example of changing these defaults.
+• |vim.json.encode()| no longer escapes the forward slash symbol by default
DIAGNOSTICS
@@ -169,6 +170,7 @@ The following new features were added.
API
• |nvim__ns_set()| can set properties for a namespace
+• |vim.json.encode()| has an option to enable forward slash escaping
DEFAULTS