mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
fix docs on regex matching, change the actual ordering of arguments to match the docs, and enforce AP_MAX_REG_MATCH in the function, should it somehow return more matches than we have allocated
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1467557 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -874,7 +874,7 @@ end
|
||||
<highlight language="lua">
|
||||
r:regex(string, pattern) -- Runs a regular expression match on a string, returning captures if matched:
|
||||
|
||||
local matches = r:regex("foo bar baz", "foo (%w+) (%S*)")
|
||||
local matches = r:regex("foo bar baz", "foo (\w+) (\S*)")
|
||||
if matches then
|
||||
r:puts("The regex matched, and the last word captured ($2) was: " .. matches[2])
|
||||
end
|
||||
|
@@ -908,8 +908,8 @@ static int lua_ap_regex(lua_State *L)
|
||||
luaL_checktype(L, 2, LUA_TSTRING);
|
||||
luaL_checktype(L, 3, LUA_TSTRING);
|
||||
r = ap_lua_check_request_rec(L, 1);
|
||||
pattern = lua_tostring(L, 2);
|
||||
source = lua_tostring(L, 3);
|
||||
source = lua_tostring(L, 2);
|
||||
pattern = lua_tostring(L, 3);
|
||||
flags = luaL_optinteger(L, 4, 0);
|
||||
|
||||
rv = ap_regcomp(®ex, pattern, flags);
|
||||
@@ -928,7 +928,7 @@ static int lua_ap_regex(lua_State *L)
|
||||
}
|
||||
|
||||
lua_newtable(L);
|
||||
for (i = 0; i <= regex.re_nsub; i++) {
|
||||
for (i = 0; i <= regex.re_nsub && i <= AP_MAX_REG_MATCH; i++) {
|
||||
lua_pushinteger(L, i);
|
||||
if (matches[i].rm_so >= 0 && matches[i].rm_eo >= 0)
|
||||
lua_pushstring(L,
|
||||
|
Reference in New Issue
Block a user