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/' },
31 description => sub { '' }),
33 $ctx->{-inbox}->{-primary_address} = 'test@example.com';
39 my $r = PublicInbox::View::msg_html($ctx, $mime);
41 while (defined(my $buf = $body->getline)) {
56 > Long and wordy reply goes here and it is split across multiple lines.
57 > We generate links to a separate full page where quoted-text is inline.
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
68 > See MAX_INLINE_QUOTED
72 my $s = Email::Simple->create(
74 From => 'a@example.com',
75 To => 'b@example.com',
76 'Content-Type' => 'text/plain',
77 'Message-ID' => '<hello@example.com>',
78 Subject => 'this is a subject',
82 my $mime = Email::MIME->new($s);
83 my $html = msg_html($mime);
86 like($html, qr!<a\nhref="raw"!s, "raw link present");
87 like($html, qr/hello world\b/, "body present");
88 like($html, qr/> keep this inline/, "short quoted text is inline");
95 attributes => { content_type => 'text/plain', },
99 attributes => { content_type => 'text/plain', },
103 my $mime = Email::MIME->create(
105 From => 'a@example.com',
107 'Message-ID' => '<blah@example.com>',
108 'In-Reply-To' => '<irp@example.com>',
113 my $html = msg_html($mime);
114 like($html, qr/hi\n.*-- Attachment #2.*\nbye\n/s, "multipart split");
117 # multipart email with attached patch
121 attributes => { content_type => 'text/plain', },
122 body => 'hi, see attached patch',
126 content_type => 'text/plain',
127 filename => "foo.patch",
129 body => "--- a/file\n+++ b/file\n" .
130 "@@ -49, 7 +49,34 @@\n",
133 my $mime = Email::MIME->create(
135 From => 'a@example.com',
136 Subject => '[PATCH] asdf',
137 'Message-ID' => '<patch@example.com>',
142 my $html = msg_html($mime);
143 like($html, qr!.*Attachment #2: foo\.patch --!,
144 "parts split with filename");
147 # multipart collapsed to single quoted-printable text/plain
152 content_type => 'text/plain',
153 encoding => 'quoted-printable',
158 my $mime = Email::MIME->create(
160 From => 'qp@example.com',
162 'Message-ID' => '<qp@example.com>',
167 my $orig = $mime->body_raw;
168 my $html = msg_html($mime);
169 like($orig, qr/hi =3D bye=/, "our test used QP correctly");
170 like($html, qr/\bhi = bye\b/, "HTML output decoded QP");
174 use PublicInbox::MID qw/id_compress/;
176 # n.b: this is probably invalid since we dropped CGI for PSGI:
177 like(id_compress('foo%bar@wtf'), qr/\A[a-f0-9]{40}\z/,
178 "percent always converted to sha1 to workaround buggy httpds");
180 is(id_compress('foobar-wtf'), 'foobar-wtf',
181 'regular ID not compressed');