From d198a105eb9a49749fa38fe8eba4da59d572292e Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Thu, 20 Feb 2020 17:58:24 +0300 Subject: [PATCH] Configuration: removing UTF-8 BOM from the input JSON. Some editors can add it to JSON files. --- src/nxt_controller.c | 7 +++++++ 1 file changed, 7 insertions(+) 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) {