feature: implemented the "J" regex option for the PCRE Javascript compatible mode in the ngx.re API. thanks lhmwzy for requesting this.

This commit is contained in:
agentzh (Yichun Zhang) 2013-01-24 11:48:51 -08:00
Родитель b8af0b925e
Коммит 07d4873968
5 изменённых файлов: 35 добавлений и 1 удалений

3
README
Просмотреть файл

@ -3573,6 +3573,9 @@ Nginx API for Lua
this option should always be used together with the 'o' option.
first introduced in ngx_lua v0.3.1rc30.
J enable the PCRE Javascript compatible mode. this option was
first introduced in the v0.7.14 release.
m multi-line mode (similar to Perl's /m modifier)
o compile-once mode (similar to Perl's /o modifier),

Просмотреть файл

@ -3293,6 +3293,9 @@ Specify `options` to control how the match operation will be performed. The foll
this option should always be used together with the 'o' option.
first introduced in ngx_lua v0.3.1rc30.
J enable the PCRE Javascript compatible mode. this option was
first introduced in the v0.7.14 release.
m multi-line mode (similar to Perl's /m modifier)
o compile-once mode (similar to Perl's /o modifier),

Просмотреть файл

@ -3179,6 +3179,9 @@ Specify <code>options</code> to control how the match operation will be performe
this option should always be used together with the 'o' option.
first introduced in ngx_lua v0.3.1rc30.
J enable the PCRE Javascript compatible mode. this option was
first introduced in the v0.7.14 release.
m multi-line mode (similar to Perl's /m modifier)
o compile-once mode (similar to Perl's /o modifier),

Просмотреть файл

@ -1102,6 +1102,10 @@ ngx_http_lua_ngx_re_parse_opts(lua_State *L, ngx_lua_regex_compile_t *re,
flags |= NGX_LUA_RE_MODE_DUPNAMES;
break;
case 'J':
re->options |= PCRE_JAVASCRIPT_COMPAT;
break;
default:
msg = lua_pushfstring(L, "unknown flag \"%c\"", *p);
return luaL_argerror(L, narg, msg);

Просмотреть файл

@ -9,7 +9,7 @@ use Test::Nginx::Socket;
repeat_each(2);
plan tests => repeat_each() * (blocks() * 2 + 6);
plan tests => repeat_each() * (blocks() * 2 + 7);
#no_diff();
no_long_string();
@ -857,3 +857,24 @@ hello-world
--- no_error_log
[error]
=== TEST 40: Javascript compatible mode
--- config
location /t {
content_by_lua '
local m = ngx.re.match("章", [[\\u7AE0]], "uJ")
if m then
ngx.say("matched: ", m[0])
else
ngx.say("not matched!")
end
';
}
--- request
GET /t
--- response_body
matched:
--- no_error_log
[error]