From 35ee442e9666cc8729839ee6f4cc064a29c8282c Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Mon, 8 Apr 2024 22:47:24 -0700 Subject: [PATCH] Modules: checking for duplicate js_set variables. This closes #700 issue on Github. --- nginx/ngx_http_js_module.c | 6 ++++++ nginx/ngx_stream_js_module.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index c6249548..21bcc26a 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -4773,6 +4773,12 @@ ngx_http_js_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) *fname = value[2]; + if (v->get_handler == ngx_http_js_variable_set) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "variable \"%V\" is already declared", &value[1]); + return NGX_CONF_ERROR; + } + v->get_handler = ngx_http_js_variable_set; v->data = (uintptr_t) fname; diff --git a/nginx/ngx_stream_js_module.c b/nginx/ngx_stream_js_module.c index f064ab04..088b5229 100644 --- a/nginx/ngx_stream_js_module.c +++ b/nginx/ngx_stream_js_module.c @@ -2217,6 +2217,12 @@ ngx_stream_js_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) *fname = value[2]; + if (v->get_handler == ngx_stream_js_variable_set) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "variable \"%V\" is already declared", &value[1]); + return NGX_CONF_ERROR; + } + v->get_handler = ngx_stream_js_variable_set; v->data = (uintptr_t) fname; -- 2.47.3