accessing $arg_PARAMETER for parameter with . in it
Maxim Dounin
mdounin at mdounin.ru
Wed Jul 11 19:14:45 UTC 2012
Hello!
On Wed, Jul 11, 2012 at 01:39:19AM -0400, bluesmoon wrote:
> Hi,
>
> I have a query string parameter that has a dot in it. For example,
> `a.b`. I need to write this parameter to my log file. How do I
> reference it?
>
> I've tried `$arg_a.b` but that prints `-.b` (ie, it prints the value of
> $arg_a which is - followed by .b)
>
> I've also tried `$arg_a_b` but that just prints `-` since there is no
> parameter a_b or a-b.
>
> What should I do?
The $arg_* variables won't allow you to access request arguments with
characters not allowed in variable names.
If you really need to, you may parse $args yourself, e.g. with
map{} directive using regular expressions. Something like this
should work:
map $args $ab {
"~(?:^|[&;])a[.]b=(?<foo>[^&;]*)" $foo;
}
Maxim Dounin
More information about the nginx
mailing list