1 # Copyright (C) 2013-2018 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
8 use_ok 'PublicInbox::View';
10 # FIXME: make this test less fragile
12 env => { HTTP_HOST => 'example.com', 'psgi.url_scheme' => 'http' },
13 -inbox => Plack::Util::inline_object(
15 search => sub { undef },
16 base_url => sub { 'http://example.com/' },
19 description => sub { '' }),
21 $ctx->{-inbox}->{-primary_address} = 'test@example.com';
27 my $r = PublicInbox::View::msg_html($ctx, $mime);
29 while (defined(my $buf = $body->getline)) {
44 > Long and wordy reply goes here and it is split across multiple lines.
45 > We generate links to a separate full page where quoted-text is inline.
49 > See MAX_INLINE_QUOTED
50 > See MAX_INLINE_QUOTED
51 > See MAX_INLINE_QUOTED
52 > See MAX_INLINE_QUOTED
53 > See MAX_INLINE_QUOTED
54 > See MAX_INLINE_QUOTED
55 > See MAX_INLINE_QUOTED
56 > See MAX_INLINE_QUOTED
60 my $s = Email::Simple->create(
62 From => 'a@example.com',
63 To => 'b@example.com',
64 'Content-Type' => 'text/plain',
65 'Message-ID' => '<hello@example.com>',
66 Subject => 'this is a subject',
70 my $mime = Email::MIME->new($s);
71 my $html = msg_html($mime);
74 like($html, qr!<a\nhref="raw"!s, "raw link present");
75 like($html, qr/hello world\b/, "body present");
76 like($html, qr/> keep this inline/, "short quoted text is inline");
83 attributes => { content_type => 'text/plain', },
87 attributes => { content_type => 'text/plain', },
91 my $mime = Email::MIME->create(
93 From => 'a@example.com',
95 'Message-ID' => '<blah@example.com>',
96 'In-Reply-To' => '<irp@example.com>',
101 my $html = msg_html($mime);
102 like($html, qr/hi\n.*-- Attachment #2.*\nbye\n/s, "multipart split");
105 # multipart email with attached patch
109 attributes => { content_type => 'text/plain', },
110 body => 'hi, see attached patch',
114 content_type => 'text/plain',
115 filename => "foo&.patch",
117 body => "--- a/file\n+++ b/file\n" .
118 "@@ -49, 7 +49,34 @@\n",
121 my $mime = Email::MIME->create(
123 From => 'a@example.com',
124 Subject => '[PATCH] asdf',
125 'Message-ID' => '<patch@example.com>',
130 my $html = msg_html($mime);
131 like($html, qr!.*Attachment #2: foo&(?:amp|#38);\.patch --!,
132 "parts split with filename");
135 # multipart collapsed to single quoted-printable text/plain
140 content_type => 'text/plain',
141 encoding => 'quoted-printable',
146 my $mime = Email::MIME->create(
148 From => 'qp@example.com',
150 'Message-ID' => '<qp@example.com>',
155 my $orig = $mime->body_raw;
156 my $html = msg_html($mime);
157 like($orig, qr/hi =3D bye=/, "our test used QP correctly");
158 like($html, qr/\bhi = bye\b/, "HTML output decoded QP");
162 use PublicInbox::MID qw/id_compress/;
164 # n.b: this is probably invalid since we dropped CGI for PSGI:
165 like(id_compress('foo%bar@wtf'), qr/\A[a-f0-9]{40}\z/,
166 "percent always converted to sha1 to workaround buggy httpds");
168 is(id_compress('foobar-wtf'), 'foobar-wtf',
169 'regular ID not compressed');