diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2023-05-25 09:38:12 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-05-25 10:50:41 +0200 |
commit | 5b4a36483719e3dbc87bde8df3f78f2c840be649 (patch) | |
tree | 026f4849fbeaf3fc65cf97e0cf79cf33c023895a /tools | |
parent | 1ec601bf411d839beddf57bf2a7728cd04582bbf (diff) |
jsdialog: encode properly control characters
according to https://www.rfc-editor.org/rfc/rfc7159#section-7
strings in JSON should contain control characters (0x00-0x1f)
encoded as \uXXXX
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I1f828f64e57328b5fa2dcf5853afe0d6ea643081
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152262
Reviewed-by: Attila Szűcs <attila.szucs@collabora.com>
Tested-by: Attila Szűcs <attila.szucs@collabora.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/misc/json_writer.cxx | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/source/misc/json_writer.cxx b/tools/source/misc/json_writer.cxx index 5bc718608d6a..95210d7e7fa7 100644 --- a/tools/source/misc/json_writer.cxx +++ b/tools/source/misc/json_writer.cxx @@ -156,6 +156,15 @@ static char getEscapementChar(char ch) static bool writeEscapedSequence(sal_uInt32 ch, char*& pos) { + // control characters + if (ch <= 0x1f) + { + int written = sprintf(pos, "\\u%.4x", ch); + if (written > 0) + pos += written; + return true; + } + switch (ch) { case '\b': |