ngx_lua location capture issue

Nginx User nginx at nginxuser.net
Fri Oct 21 14:00:53 UTC 2011


On 21 October 2011 07:13, agentzh <agentzh at gmail.com> wrote:
> BTW, it's bad practice to match against $request_uri directly because
> query strings may be escaped according to URI escaping rules. (Yes!
> there's escaping everywhere!)
That's a great point. ngx.unescape.uri helps get over this.

Better still yet, it is the actual arguments I need to be matching
against and that was just an initial setup thing.

I have since moved on to ....

	local args = ngx.req.get_uri_args()
	for key, val in pairs(args) do
		if type(val) == "table" then
			my_arg = table.concat(val, ", ")
		else
			my_arg =  val
		end
		if my_arg then
                       local query_string = ngx.re.match(my_arg,
"regex_1", "io")
                       ...
                       local query_string = ngx.re.match(my_arg,
"regex_n", "io")
                       ...
                end
         end

The val entities are url unescaped by ngx_lua so no issues with that.

Now that this is all working fine (after using "\\\" in place of the
documented "\\" to get it to actually work - and it does work while
the "correct" version does not), I can get back trying out the
location capture again.

Will let you know how that goes in a new thread since I have derailed
this one with the regex issue.

Cheers!



More information about the nginx mailing list