HTTP: allow hyphens in variable names inside ${}.

Currently, nginx variables cannot contain hyphens. This makes it
impossible to access request arguments like "?my-param=123" directly.

The expression "$arg_my-param" is currently parsed as the variable
"$arg_my" followed by the literal string "-param", rather than a single
variable "$arg_my-param".

This patch adds support for hyphens in variable names, but only when
enclosed in curly braces. Now it is possible to use "${arg_my-param}".

Variables without braces (e.g. "$foo-bar") remain unchanged to preserve
compatibility with existing configurations where hyphens are used as
separators.
This commit is contained in:
Andrey Kolyshkin 2025-12-03 13:42:26 +03:00
parent ab4f5b2d32
commit a1f83eab01
1 changed files with 4 additions and 0 deletions

View File

@ -535,6 +535,10 @@ ngx_http_script_compile(ngx_http_script_compile_t *sc)
continue;
}
if (ch == '-' && bracket) {
continue;
}
break;
}