X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fplack.t;h=a5fd54c9981c3c845b05262085e789ed6b867155;hb=d07ba9c30800225052d17ccca458afbfa05a8ff0;hp=40ff2baa72739e72d80b2b2969327b899a7df37e;hpb=60196eedef969743a76f915825b741b69ed1c171;p=public-inbox.git diff --git a/t/plack.t b/t/plack.t index 40ff2baa..a5fd54c9 100644 --- a/t/plack.t +++ b/t/plack.t @@ -10,17 +10,24 @@ require_mods(@mods); foreach my $mod (@mods) { use_ok $mod; } ok(-f $psgi, "psgi example file found"); my $pfx = 'http://example.com/test'; -# ensure successful message delivery -my $ibx = create_inbox('test', sub { +my $eml = eml_load('t/iso-2202-jp.eml'); +# ensure successful message deliveries +my $ibx = create_inbox('test-1', sub { my ($im, $ibx) = @_; my $addr = $ibx->{-primary_address}; - $im->add(PublicInbox::Eml->new(<add'; + $im->add($eml) or xbail '->add'; + $eml->header_set('Content-Type', + "text/plain; charset=\rso\rb\0gus\rithurts"); + $eml->header_set('Message-ID', ''); + $im->add($eml) or xbail '->add'; + $im->add(PublicInbox::Eml->new(<add'; From: Me To: You Cc: $addr Message-Id: Subject: hihi Date: Fri, 02 Oct 1993 00:00:00 +0000 +Content-Type: text/plain; charset=iso-8859-1 > quoted text zzzzzz @@ -78,6 +85,7 @@ test_psgi($app, sub { my ($cb) = @_; my $res = $cb->(GET('http://example.com/test/crlf@example.com/')); is($res->code, 200, 'retrieved CRLF as HTML'); + like($res->content, qr/mailto:me\@example/, 'no %40, per RFC 6068'); unlike($res->content, qr/\r/, 'no CR in HTML'); $res = $cb->(GET('http://example.com/test/crlf@example.com/raw')); is($res->code, 200, 'retrieved CRLF raw'); @@ -195,6 +203,19 @@ test_psgi($app, sub { my $res = $cb->(GET($pfx . '/blah@example.com/raw')); is(200, $res->code, 'success response received for /*/raw'); like($res->content, qr!^From !sm, "mbox returned"); + is($res->header('Content-Type'), 'text/plain; charset=iso-8859-1', + 'charset from message used'); + + $res = $cb->(GET($pfx . '/broken@example.com/raw')); + is($res->header('Content-Type'), 'text/plain; charset=UTF-8', + 'broken charset ignored'); + + $res = $cb->(GET($pfx . '/199707281508.AAA24167@hoyogw.example/raw')); + is($res->header('Content-Type'), 'text/plain; charset=ISO-2022-JP', + 'ISO-2002-JP returned'); + chomp(my $body = $res->content); + my $raw = PublicInbox::Eml->new(\$body); + is($raw->body_raw, $eml->body_raw, 'ISO-2022-JP body unmodified'); $res = $cb->(GET($pfx . '/blah@example.com/t.mbox.gz')); is(501, $res->code, '501 when overview missing');