summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2020-02-20 17:58:24 +0300
committerValentin Bartenev <vbart@nginx.com>2020-02-20 17:58:24 +0300
commitd198a105eb9a49749fa38fe8eba4da59d572292e (patch)
tree09aa4cb7ba029949f2ddb43dd7920693cf29ecda /src
parent044b3afcdab3bc434f9340e97e83e37c5227be36 (diff)
downloadunit-d198a105eb9a49749fa38fe8eba4da59d572292e.tar.gz
unit-d198a105eb9a49749fa38fe8eba4da59d572292e.tar.bz2
Configuration: removing UTF-8 BOM from the input JSON.
Some editors can add it to JSON files.
Diffstat (limited to 'src')
-rw-r--r--src/nxt_controller.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/nxt_controller.c b/src/nxt_controller.c
index 86ba1246..cc1ed534 100644
--- a/src/nxt_controller.c
+++ b/src/nxt_controller.c
@@ -989,6 +989,13 @@ nxt_controller_process_config(nxt_task_t *task, nxt_controller_request_t *req,
nxt_memzero(&error, sizeof(nxt_conf_json_error_t));
+ /* Skip UTF-8 BOM. */
+ if (nxt_buf_mem_used_size(mbuf) >= 3
+ && nxt_memcmp(mbuf->pos, "\xEF\xBB\xBF", 3) == 0)
+ {
+ mbuf->pos += 3;
+ }
+
value = nxt_conf_json_parse(mp, mbuf->pos, mbuf->free, &error);
if (value == NULL) {