File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -944,7 +944,11 @@ ngx_http_lua_ngx_re_gmatch_iterator(lua_State *L)
944
944
}
945
945
946
946
offset = cap [1 ];
947
- if (offset == (ssize_t ) subj .len ) {
947
+ if (offset == cap [0 ]) {
948
+ offset ++ ;
949
+ }
950
+
951
+ if (offset >= (ssize_t ) subj .len ) {
948
952
offset = -1 ;
949
953
950
954
if (!(ctx -> flags & NGX_LUA_RE_COMPILE_ONCE )) {
Original file line number Diff line number Diff line change @@ -486,3 +486,27 @@ sr failed: 500
486
486
-- - error_log
487
487
attempt to use ngx. re . gmatch iterator in a request that did not create it
488
488
489
+
490
+
491
+ === TEST 20 : gmatch (empty matched string)
492
+ -- - config
493
+ location / re {
494
+ content_by_lua '
495
+ for m in ngx.re.gmatch("hello", "a|") do
496
+ if m then
497
+ ngx.say("matched: [", m[0], "]")
498
+ else
499
+ ngx.say("not matched: ", m)
500
+ end
501
+ end
502
+ ' ;
503
+ }
504
+ -- - request
505
+ GET / re
506
+ -- - response_body
507
+ matched: []
508
+ matched: []
509
+ matched: []
510
+ matched: []
511
+ matched: []
512
+
You can’t perform that action at this time.
0 commit comments