openresty / lua-nginx-module

Embed the Power of Lua into NGINX HTTP servers
https://openresty.org/
11.3k stars 2.03k forks source link

ngx.re.match throw exception when match � #786

Open LuciferoO opened 8 years ago

LuciferoO commented 8 years ago

Hello,Agentzh: I use Lua to build a WAF on nginx, but I met a problem that When I request a URI like "1.php?id=1%df%27%20and%20%271%27=%271" The ngx.re.match throw a exception: pcre_exec() failed: -10 on "1�' and '1'='1" using

but when I give Chinese to it, it works.
1.php?id=%E6%88%91%E6%98%AF%E4%BD%A0 

Can you help me to solve the problem , thank you very much.
agentzh commented 8 years ago

@LuciferoO The PCRE error code -10 means "bad UTF-8". It seems that you're passing invalid UTF-8 sequences while asking PCRE to do UTF-8 mode. You can use the U regex option to disable the UTF-8 sanity check. See https://github.com/openresty/lua-nginx-module#ngxrematch