diff options
author | Dmitry Volyntsev <xeioex@nginx.com> | 2024-04-22 17:51:45 -0700 |
---|---|---|
committer | Dmitry Volyntsev <xeioex@nginx.com> | 2024-04-22 17:51:45 -0700 |
commit | 5ab8d47c6d59ce21feae1541d4b7acb1289570dc (patch) | |
tree | 667f251a8286c035f9d1a661eba35478478d7f6c /nginx/ngx_http_js_module.c | |
parent | 8b22e722b345c383e789e98533200e98975e5425 (diff) | |
download | njs-5ab8d47c6d59ce21feae1541d4b7acb1289570dc.tar.gz njs-5ab8d47c6d59ce21feae1541d4b7acb1289570dc.zip |
Modules: improved checking for duplicate js_set variables.
Since 6fb1aca4eeaf (0.8.4) the identical js_set variables introduced as
a part of an include file that is shared amongst multiple vhosts are
rejected during configuration parsing.
The patch ignores duplicate js_set variables when they refer to the same
JS function.
This fixes #705 issue on Github.
Diffstat (limited to 'nginx/ngx_http_js_module.c')
-rw-r--r-- | nginx/ngx_http_js_module.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index ef494d48..d280ca0f 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -4732,7 +4732,7 @@ invalid: static char * ngx_http_js_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { - ngx_str_t *value, *fname; + ngx_str_t *value, *fname, *prev; ngx_http_variable_t *v; value = cf->args->elts; @@ -4759,9 +4759,16 @@ 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; + prev = (ngx_str_t *) v->data; + + if (fname->len != prev->len + || ngx_strncmp(fname->data, prev->data, fname->len) != 0) + { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "variable \"%V\" is redeclared with " + "different function name", &value[1]); + return NGX_CONF_ERROR; + } } v->get_handler = ngx_http_js_variable_set; |