[nginx-tests] Tests: added rewrite test with nested captures.

Maxim Dounin mdounin at mdounin.ru
Tue May 26 01:00:53 UTC 2026


details:   http://freenginx.org/hg/nginx-tests/rev/33e21ea3de32
branches:  
changeset: 2061:33e21ea3de32
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Tue May 26 03:23:15 2026 +0300
description:
Tests: added rewrite test with nested captures.

diffstat:

 rewrite.t |  20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diffs (44 lines):

diff --git a/rewrite.t b/rewrite.t
--- a/rewrite.t
+++ b/rewrite.t
@@ -21,7 +21,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http rewrite proxy/)->plan(24)
+my $t = Test::Nginx->new()->has(qw/http rewrite proxy/)->plan(25)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -137,6 +137,11 @@ http {
             return 200 "uri:$uri args:$args";
         }
 
+        location /capture_nested {
+            rewrite ^((.*)) /?c=$1&d=$2;
+            return 200 "uri:$uri args:$args";
+        }
+
         location /break {
             rewrite ^ /return200;
             break;
@@ -256,6 +261,19 @@ like(http_get('/capture_another/%25?a=b'
 
 }
 
+TODO: {
+local $TODO = 'not yet'
+	unless $t->has_version('1.31.2');
+todo_skip 'might coredump', 1
+	unless $t->has_version('1.31.2')
+	or $ENV{TEST_NGINX_UNSAFE};
+
+like(http_get('/capture_nested/%25?a=b'),
+	qr!^uri:/ args:c=/capture_nested/%25&d=/capture_nested/%25&a=b$!ms,
+	'escape with nested captures');
+
+}
+
 # break
 
 like(http_get('/break'), qr/200/, 'valid_location reset');


More information about the nginx-devel mailing list