[nginx-tests] Tests: charset tests with invalid characters in mu...
Maxim Dounin
mdounin at mdounin.ru
Fri Jun 26 18:30:57 UTC 2026
details: http://freenginx.org/hg/nginx-tests/rev/f74feb70418c
branches:
changeset: 2075:f74feb70418c
user: Maxim Dounin <mdounin at mdounin.ru>
date: Fri Jun 26 21:08:39 2026 +0300
description:
Tests: charset tests with invalid characters in multiple buffers.
diffstat:
charset_perl.t | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
diffs (68 lines):
diff --git a/charset_perl.t b/charset_perl.t
--- a/charset_perl.t
+++ b/charset_perl.t
@@ -21,7 +21,7 @@ use Test::Nginx;
select STDERR; $| = 1;
select STDOUT; $| = 1;
-my $t = Test::Nginx->new()->has(qw/http charset perl/)->plan(1)
+my $t = Test::Nginx->new()->has(qw/http charset perl/)->plan(2)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
@@ -78,6 +78,38 @@ http {
return OK;
}';
}
+
+ location /invalid {
+ perl 'sub {
+ my $r = shift;
+ $r->send_http_header("text/html");
+ return OK if $r->header_only;
+
+ # 2-byte invalid character
+
+ $r->print("\xc2\x61");
+ $r->print("\xc2");
+ $r->print("\x61");
+
+ # 3-byte invalid character
+
+ $r->print("\xe2\x61\x61");
+ $r->print("\xe2");
+ $r->print("\x61");
+ $r->print("\x61");
+
+ # 4-byte invalid character
+
+ $r->print("\xf0\x61\x61\x61");
+
+ $r->print("\xf0");
+ $r->print("\x61");
+ $r->print("\x61");
+ $r->print("\x61");
+
+ return OK;
+ }';
+ }
}
}
@@ -98,4 +130,16 @@ like(http_get('/multi'), qr/^CCTT𐀀
}
+TODO: {
+local $TODO = 'not yet'
+ unless $t->has_version('1.31.3');
+todo_skip 'might coredump', 1
+ unless $t->has_version('1.31.3')
+ or $ENV{TEST_NGINX_UNSAFE};
+
+like(http_get('/invalid'), qr/^\Q???a?a?aa?aa\E$/m,
+ 'invalid in multiple buffers');
+
+}
+
###############################################################################
More information about the nginx-devel
mailing list