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 },
29 description => sub { '' }),
31 $ctx->{-inbox}->{-primary_address} = 'test@example.com';
37 my $r = PublicInbox::View::msg_html($ctx, $mime);
39 while (defined(my $buf = $body->getline)) {
54 > Long and wordy reply goes here and it is split across multiple lines.
55 > We generate links to a separate full page where quoted-text is inline.
59 > See MAX_INLINE_QUOTED
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
70 my $s = Email::Simple->create(
72 From => 'a@example.com',
73 To => 'b@example.com',
74 'Content-Type' => 'text/plain',
75 'Message-ID' => '<hello@example.com>',
76 Subject => 'this is a subject',
80 my $mime = Email::MIME->new($s);
81 my $html = msg_html($mime);
84 like($html, qr!<a\nhref="raw"!s, "raw link present");
85 like($html, qr/hello world\b/, "body present");
86 like($html, qr/> keep this inline/, "short quoted text is inline");
93 attributes => { content_type => 'text/plain', },
97 attributes => { content_type => 'text/plain', },
101 my $mime = Email::MIME->create(
103 From => 'a@example.com',
105 'Message-ID' => '<blah@example.com>',
106 'In-Reply-To' => '<irp@example.com>',
111 my $html = msg_html($mime);
112 like($html, qr/hi\n.*-- Attachment #2.*\nbye\n/s, "multipart split");
115 # multipart email with attached patch
119 attributes => { content_type => 'text/plain', },
120 body => 'hi, see attached patch',
124 content_type => 'text/plain',
125 filename => "foo.patch",
127 body => "--- a/file\n+++ b/file\n" .
128 "@@ -49, 7 +49,34 @@\n",
131 my $mime = Email::MIME->create(
133 From => 'a@example.com',
134 Subject => '[PATCH] asdf',
135 'Message-ID' => '<patch@example.com>',
140 my $html = msg_html($mime);
141 like($html, qr!.*Attachment #2: foo\.patch --!,
142 "parts split with filename");
145 # multipart collapsed to single quoted-printable text/plain
150 content_type => 'text/plain',
151 encoding => 'quoted-printable',
156 my $mime = Email::MIME->create(
158 From => 'qp@example.com',
160 'Message-ID' => '<qp@example.com>',
165 my $orig = $mime->body_raw;
166 my $html = msg_html($mime);
167 like($orig, qr/hi =3D bye=/, "our test used QP correctly");
168 like($html, qr/\bhi = bye\b/, "HTML output decoded QP");
172 use PublicInbox::MID qw/id_compress/;
174 # n.b: this is probably invalid since we dropped CGI for PSGI:
175 like(id_compress('foo%bar@wtf'), qr/\A[a-f0-9]{40}\z/,
176 "percent always converted to sha1 to workaround buggy httpds");
178 is(id_compress('foobar-wtf'), 'foobar-wtf',
179 'regular ID not compressed');