changeset 1714:e4e711d07e6c

Tests: added URI tests with forbidden control characters.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 29 Jun 2021 11:58:21 +0300
parents 77a9e393ed46
children 3604ef83c1aa
files h2_headers.t http_uri.t
diffstat 2 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/h2_headers.t
+++ b/h2_headers.t
@@ -23,7 +23,7 @@ use Test::Nginx::HTTP2;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(104)
+my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(105)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -1058,6 +1058,16 @@ is($frame->{headers}->{':status'}, 400, 
 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
 is($frame->{headers}->{':status'}, 400, 'invalid path');
 
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.21.1');
+
+$sid = $s->new_stream({ path => "/t1.html\x02" });
+$frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
+
+($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
+is($frame->{headers}->{':status'}, 400, 'invalid path control');
+
+}
 
 # ngx_http_v2_parse_int() error handling
 
--- a/http_uri.t
+++ b/http_uri.t
@@ -22,7 +22,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(17)
+my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(19)
 	->write_file_expand('nginx.conf', <<'EOF')->run();
 
 %%TEST_GLOBALS%%
@@ -83,4 +83,13 @@ like(http_get('/ /'), qr/400 Bad/, 'spac
 
 }
 
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.21.1');
+
+like(http_get("/\x02"), qr/400 Bad/, 'control');
+
+}
+
+like(http_get('/%02'), qr!x /\x02 x!, 'control escaped');
+
 ###############################################################################