Configuration: removing UTF-8 BOM from the input JSON.

Some editors can add it to JSON files.
This commit is contained in:
Valentin Bartenev
2020-02-20 17:58:24 +03:00
parent 044b3afcda
commit d198a105eb

View File

@@ -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) {