]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/eml.t
eml: rename limits to match postfix names
[public-inbox.git] / t / eml.t
diff --git a/t/eml.t b/t/eml.t
index 43c735e76b9e466aa3d62f256492e36540608743..c91deb3ab29a8a1a78f3a186af3188dca7b68925 100644 (file)
--- a/t/eml.t
+++ b/t/eml.t
@@ -252,12 +252,37 @@ EOF
                'final "\n" preserved on missing epilogue');
 }
 
+if ('header_size_limit stolen from postfix') {
+       local $PublicInbox::Eml::header_size_limit = 4;
+       my @w;
+       local $SIG{__WARN__} = sub { push @w, @_ };
+       my $eml = PublicInbox::Eml->new("a:b\na:d\n\nzz");
+       is_deeply([$eml->header('a')], ['b'], 'no overrun header');
+       is($eml->body_raw, 'zz', 'body not damaged');
+       is($eml->header_obj->as_string, "a:b\n", 'header truncated');
+       is(grep(/truncated/, @w), 1, 'truncation warned');
+
+       $eml = PublicInbox::Eml->new("a:b\na:d\n");
+       is_deeply([$eml->header('a')], ['b'], 'no overrun header w/o body');
+
+       local $PublicInbox::Eml::header_size_limit = 5;
+       $eml = PublicInbox::Eml->new("a:b\r\na:d\r\n\nzz");
+       is_deeply([$eml->header('a')], ['b'], 'no overrun header on CRLF');
+       is($eml->body_raw, 'zz', 'body not damaged');
+
+       @w = ();
+       $eml = PublicInbox::Eml->new("too:long\n");
+       $eml = PublicInbox::Eml->new("too:long\n\n");
+       $eml = PublicInbox::Eml->new("too:long\r\n\r\n");
+       is(grep(/ignored/, @w), 3, 'ignored header warned');
+}
+
 if ('maxparts is a feature unique to us') {
        my $eml = eml_load 't/psgi_attach.eml';
        my @orig;
        $eml->each_part(sub { push @orig, $_[0]->[0] });
 
-       local $PublicInbox::Eml::MAXPARTS = scalar(@orig);
+       local $PublicInbox::Eml::mime_parts_limit = scalar(@orig);
        my $i = 0;
        $eml->each_part(sub {
                my $cur = $_[0]->[0];
@@ -265,7 +290,7 @@ if ('maxparts is a feature unique to us') {
                is($cur->body_raw, $prv->body_raw, "part #$i matches");
        });
        is($i, scalar(@orig), 'maxparts honored');
-       $PublicInbox::Eml::MAXPARTS--;
+       $PublicInbox::Eml::mime_parts_limit--;
        my @ltd;
        $eml->each_part(sub { push @ltd, $_[0]->[0] });
        for ($i = 0; $i <= $#ltd; $i++) {