If query parameters in the request looks like this
/something.cgi?param_name=1¶m-name=2
I can access ‘param_name’ as $arg_param_name. How do I access
‘param-name’
though? $arg_param-name will not work since as far as nginx is concerned
the
variable name ends at $arg_param. Is there a workaround for this case?
Has
anyone else run into a similar problem?
On Wed, Nov 12, 2014 at 03:38:03AM -0500, sudarshan wrote:
Hi there,
If query parameters in the request looks like this
/something.cgi?param_name=1¶m-name=2
I can access ‘param_name’ as $arg_param_name. How do I access ‘param-name’
though? $arg_param-name will not work since as far as nginx is concerned the
variable name ends at $arg_param. Is there a workaround for this case? Has
anyone else run into a similar problem?
If you want to avoid embedded languages, you could match-and-extract
from $args, either with a map or an if, to set your variable name to
the matching value in “&?param-name=([^&]*)”.
But it might be less work to change the input to restrict itself to
nginx-friendly characters.
While this may currently work, I wouldn’t recommend relying on
this - as this is rather a bug than a desired behaviour. This
will stop working as long as support for multiple variables will
be added to map.
Instead, I would recommend to use regexp-based parsing of the
$args variable as Francis suggests. This can be done trivially
with map, like this: