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)
8 use_ok 'PublicInbox::View';
17 my $expect = shift @q;
18 my $res = PublicInbox::View::squote_maybe($input);
19 is($res, $expect, "quote $input => $res");
22 # FIXME: make this test less fragile
24 env => { HTTP_HOST => 'example.com', 'psgi.url_scheme' => 'http' },
25 -inbox => Plack::Util::inline_object(
27 search => sub { undef },
28 base_url => sub { 'http://example.com/' },
30 description => sub { '' }),
32 $ctx->{-inbox}->{-primary_address} = 'test@example.com';
38 my $r = PublicInbox::View::msg_html($ctx, $mime);
40 while (defined(my $buf = $body->getline)) {
55 > Long and wordy reply goes here and it is split across multiple lines.
56 > We generate links to a separate full page where quoted-text is inline.
60 > See MAX_INLINE_QUOTED
61 > See MAX_INLINE_QUOTED
62 > See MAX_INLINE_QUOTED
63 > See MAX_INLINE_QUOTED
64 > See MAX_INLINE_QUOTED
65 > See MAX_INLINE_QUOTED
66 > See MAX_INLINE_QUOTED
67 > See MAX_INLINE_QUOTED
71 my $s = Email::Simple->create(
73 From => 'a@example.com',
74 To => 'b@example.com',
75 'Content-Type' => 'text/plain',
76 'Message-ID' => '<hello@example.com>',
77 Subject => 'this is a subject',
81 my $mime = Email::MIME->new($s);
82 my $html = msg_html($mime);
85 like($html, qr!<a\nhref="raw"!s, "raw link present");
86 like($html, qr/hello world\b/, "body present");
87 like($html, qr/> keep this inline/, "short quoted text is inline");
94 attributes => { content_type => 'text/plain', },
98 attributes => { content_type => 'text/plain', },
102 my $mime = Email::MIME->create(
104 From => 'a@example.com',
106 'Message-ID' => '<blah@example.com>',
107 'In-Reply-To' => '<irp@example.com>',
112 my $html = msg_html($mime);
113 like($html, qr/hi\n.*-- Attachment #2.*\nbye\n/s, "multipart split");
116 # multipart email with attached patch
120 attributes => { content_type => 'text/plain', },
121 body => 'hi, see attached patch',
125 content_type => 'text/plain',
126 filename => "foo.patch",
128 body => "--- a/file\n+++ b/file\n" .
129 "@@ -49, 7 +49,34 @@\n",
132 my $mime = Email::MIME->create(
134 From => 'a@example.com',
135 Subject => '[PATCH] asdf',
136 'Message-ID' => '<patch@example.com>',
141 my $html = msg_html($mime);
142 like($html, qr!.*Attachment #2: foo\.patch --!,
143 "parts split with filename");
146 # multipart collapsed to single quoted-printable text/plain
151 content_type => 'text/plain',
152 encoding => 'quoted-printable',
157 my $mime = Email::MIME->create(
159 From => 'qp@example.com',
161 'Message-ID' => '<qp@example.com>',
166 my $orig = $mime->body_raw;
167 my $html = msg_html($mime);
168 like($orig, qr/hi =3D bye=/, "our test used QP correctly");
169 like($html, qr/\bhi = bye\b/, "HTML output decoded QP");
173 use PublicInbox::MID qw/id_compress/;
175 # n.b: this is probably invalid since we dropped CGI for PSGI:
176 like(id_compress('foo%bar@wtf'), qr/\A[a-f0-9]{40}\z/,
177 "percent always converted to sha1 to workaround buggy httpds");
179 is(id_compress('foobar-wtf'), 'foobar-wtf',
180 'regular ID not compressed');