1 # Copyright (C) 2013-2015 all contributors <meta@public-inbox.org>
2 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
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 },
17 description => sub { '' }),
19 $ctx->{-inbox}->{-primary_address} = 'test@example.com';
25 my $body = PublicInbox::View::msg_html($ctx, $mime);
26 while (defined(my $buf = $body->getline)) {
41 > Long and wordy reply goes here and it is split across multiple lines.
42 > We generate links to a separate full page where quoted-text is inline.
46 > See MAX_INLINE_QUOTED
47 > See MAX_INLINE_QUOTED
48 > See MAX_INLINE_QUOTED
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
57 my $s = Email::Simple->create(
59 From => 'a@example.com',
60 To => 'b@example.com',
61 'Content-Type' => 'text/plain',
62 'Message-ID' => '<hello@example.com>',
63 Subject => 'this is a subject',
67 my $mime = Email::MIME->new($s);
68 my $html = msg_html($mime);
71 like($html, qr!<a\nhref="raw"!s, "raw link present");
72 like($html, qr/hello world\b/, "body present");
73 like($html, qr/> keep this inline/, "short quoted text is inline");
80 attributes => { content_type => 'text/plain', },
84 attributes => { content_type => 'text/plain', },
88 my $mime = Email::MIME->create(
90 From => 'a@example.com',
92 'Message-ID' => '<blah@example.com>',
93 'In-Reply-To' => '<irp@example.com>',
98 my $html = msg_html($mime);
99 like($html, qr/hi\n.*-- Attachment #2.*\nbye\n/s, "multipart split");
102 # multipart email with attached patch
106 attributes => { content_type => 'text/plain', },
107 body => 'hi, see attached patch',
111 content_type => 'text/plain',
112 filename => "foo.patch",
114 body => "--- a/file\n+++ b/file\n" .
115 "@@ -49, 7 +49,34 @@\n",
118 my $mime = Email::MIME->create(
120 From => 'a@example.com',
121 Subject => '[PATCH] asdf',
122 'Message-ID' => '<patch@example.com>',
127 my $html = msg_html($mime);
128 like($html, qr!.*Attachment #2: foo\.patch --!,
129 "parts split with filename");
132 # multipart collapsed to single quoted-printable text/plain
137 content_type => 'text/plain',
138 encoding => 'quoted-printable',
143 my $mime = Email::MIME->create(
145 From => 'qp@example.com',
147 'Message-ID' => '<qp@example.com>',
152 my $orig = $mime->body_raw;
153 my $html = msg_html($mime);
154 like($orig, qr/hi =3D bye=/, "our test used QP correctly");
155 like($html, qr/\bhi = bye\b/, "HTML output decoded QP");
159 use PublicInbox::MID qw/id_compress/;
161 # n.b: this is probably invalid since we dropped CGI for PSGI:
162 like(id_compress('foo%bar@wtf'), qr/\A[a-f0-9]{40}\z/,
163 "percent always converted to sha1 to workaround buggy httpds");
165 is(id_compress('foobar-wtf'), 'foobar-wtf',
166 'regular ID not compressed');