Hello!
On Sat, Jun 21, 2014 at 6:28 PM, kcole wrote:
> I am using the resty.upload module to facilitate saving large files. While
> attempting to distill the header data from the multipart form upload so I
> can pass that information to the backend I've run in to a strange issue
> where ngx_lua's interpretation seems to defy standard lua interpreters
> quotation escapes.
>
[...]
> ... [error] 1588#0: *139 failed to load inlined Lua code: content_by_lua:35:
> ')' expected near '", "', ...
>
When you inline Lua code directly in nginx.conf, you should be careful
about nginx strings' escaping rules because your Lua code itself is in
a big nginx string literal.
See https://github.com/openresty/lua-nginx-module#special-pcre-sequences
for more details.
> Code
> Given s => filename="small_capture.svs"
>
> local filter = "%s?([^=]+)=\"([^=]*)\"%s?"
> local k,v = string.match(s, filter)
>
Generally, if this snippet is in nginx.conf, then you should escape
every "\" twice to make nginx's configuration file parser happy first.
Better put your Lua code in an external .lua file and reference the
file by its path in content_by_lua_file to avoid such escaping
pitfalls.
Regards,
-agentzh