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)
17 > Long and wordy reply goes here and it is split across multiple lines.
18 > We generate links to a separate full page where quoted-text is inline.
22 > See MAX_INLINE_QUOTED
23 > See MAX_INLINE_QUOTED
24 > See MAX_INLINE_QUOTED
25 > See MAX_INLINE_QUOTED
26 > See MAX_INLINE_QUOTED
27 > See MAX_INLINE_QUOTED
28 > See MAX_INLINE_QUOTED
29 > See MAX_INLINE_QUOTED
33 my $s = Email::Simple->create(
35 From => 'a@example.com',
36 To => 'b@example.com',
37 'Content-Type' => 'text/plain',
38 'Message-ID' => '<hello@example.com>',
39 Subject => 'this is a subject',
43 my $mime = Email::MIME->new($s);
44 my $html = PublicInbox::View::msg_html(undef, $mime);
47 like($html, qr!<a\nhref="\.\./raw"!s, "raw link present");
48 like($html, qr/hello world\b/, "body present");
49 like($html, qr/> keep this inline/, "short quoted text is inline");
50 like($html, qr/<a\nid=[^>]+><\/a>> Long and wordy/,
51 "long quoted text is anchored");
54 my $pfx = "../hello%40example.com/f/";
55 $mime = Email::MIME->new($s);
56 my $short = PublicInbox::View::msg_html(undef, $mime, $pfx);
57 like($short, qr!<a\nhref="\.\./hello%40example\.com/f/!s,
59 like($short, qr/\n> keep this inline/,
60 "short quoted text is inline");
61 like($short, qr/<a\nhref="\Q$pfx\E#[^>]+>Long and wordy/,
62 "long quoted text is made into a link");
63 ok(length($short) < length($html), "short page is shorter");
70 attributes => { content_type => 'text/plain', },
74 attributes => { content_type => 'text/plain', },
78 my $mime = Email::MIME->create(
80 From => 'a@example.com',
82 'Message-ID' => '<blah@example.com>',
83 'In-Reply-To' => '<irp@example.com>',
88 my $html = PublicInbox::View::msg_html(undef, $mime);
89 like($html, qr/hi\n-+ part #2 -+\nbye\n/, "multipart split");
92 # multipart email with attached patch
96 attributes => { content_type => 'text/plain', },
97 body => 'hi, see attached patch',
101 content_type => 'text/plain',
102 filename => "foo.patch",
104 body => "--- a/file\n+++ b/file\n" .
105 "@@ -49, 7 +49,34 @@\n",
108 my $mime = Email::MIME->create(
110 From => 'a@example.com',
111 Subject => '[PATCH] asdf',
112 'Message-ID' => '<patch@example.com>',
117 my $html = PublicInbox::View::msg_html(undef, $mime);
118 like($html, qr!see attached patch\n-+ foo\.patch -+\n--- a/file\n!,
119 "parts split with filename");
122 # multipart collapsed to single quoted-printable text/plain
127 content_type => 'text/plain',
128 encoding => 'quoted-printable',
133 my $mime = Email::MIME->create(
135 From => 'qp@example.com',
137 'Message-ID' => '<qp@example.com>',
142 my $orig = $mime->body_raw;
143 my $html = PublicInbox::View::msg_html(undef, $mime);
144 like($orig, qr/hi =3D bye=/, "our test used QP correctly");
145 like($html, qr/\bhi = bye\b/, "HTML output decoded QP");
149 use PublicInbox::MID qw/id_compress/;
150 like(id_compress('foo%bar@wtf'), qr/\A[a-f0-9]{40}\z/,
151 "percent always converted to sha1 to workaround buggy httpds");
152 is(id_compress('foobar-wtf'), 'foobar-wtf',
153 'regular ID not compressed');