summaryrefslogtreecommitdiff
path: root/src/cli_common.h
diff options
context:
space:
mode:
authorYuta Hongo <yutago@gmail.com>2022-03-06 04:25:52 +0900
committerGitHub <noreply@github.com>2022-03-05 21:25:52 +0200
commite3ef73dc2a557232c60c732705e8e6ff2050eba9 (patch)
tree800f7f5d873caebefb0fe940935be59be6735cf3 /src/cli_common.h
parentaf6d5c5932fa4fc1a0461af5e3df50e9c284c4f9 (diff)
downloadredis-e3ef73dc2a557232c60c732705e8e6ff2050eba9.tar.gz
redis-cli: Better --json Unicode support and --quoted-json (#10286)
Normally, `redis-cli` escapes non-printable data received from Redis, using a custom scheme (which is also used to handle quoted input). When using `--json` this is not desired as it is not compatible with RFC 7159, which specifies JSON strings are assumed to be Unicode and how they should be escaped. This commit changes `--json` to follow RFC 7159, which means that properly encoded Unicode strings in Redis will result with a valid Unicode JSON. However, this introduces a new problem with `--json` and data that is not valid Unicode (e.g., random binary data, text that follows other encoding, etc.). To address this, we add `--quoted-json` which produces JSON strings that follow the original redis-cli quoting scheme. For example, a value that consists of only null (0x00) bytes will show up as: * `"\u0000\u0000\u0000"` when using `--json` * `"\\x00\\x00\\x00"` when using `--quoted-json`
Diffstat (limited to 'src/cli_common.h')
-rw-r--r--src/cli_common.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cli_common.h b/src/cli_common.h
index 1cb76c6b9..c5c4c11aa 100644
--- a/src/cli_common.h
+++ b/src/cli_common.h
@@ -48,4 +48,7 @@ sds unquoteCString(char *str);
void parseRedisUri(const char *uri, const char* tool_name, cliConnInfo *connInfo, int *tls_flag);
void freeCliConnInfo(cliConnInfo connInfo);
+
+sds escapeJsonString(sds s, const char *p, size_t len);
+
#endif /* __CLICOMMON_H */