2 # Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::TestCommon;
9 use PublicInbox::Inbox;
10 my $have_xml_treepp = eval { require XML::TreePP; 1 };
11 my ($tmpdir, $for_destroy) = tmpdir();
14 my $res = PublicInbox::Feed::generate($_[0]);
17 while (defined(my $chunk = $body->getline)) {
24 my $git_dir = "$tmpdir/gittest";
25 my $ibx = create_inbox 'v1', tmpdir => $git_dir, sub {
27 foreach my $i (1..6) {
28 $im->add(PublicInbox::Eml->new(<<EOF)) or BAIL_OUT;
29 From: ME <me\@example.com>
30 To: U <u\@example.com>
31 Message-Id: <$i\@example.com>
33 Date: Thu, 01 Jan 1970 00:00:00 +0000
40 > this is a short quote
47 $ibx->{url} = [ 'http://example.com/test' ];
49 my $im = $ibx->importer(0);
55 my $feed = string_feed({ ibx => $ibx });
57 skip 'XML::TreePP missing', 3 unless $have_xml_treepp;
58 my $t = XML::TreePP->new->parse($feed);
59 like($t->{feed}->{-xmlns}, qr/\bAtom\b/,
60 'looks like an an Atom feed');
61 is(scalar @{$t->{feed}->{entry}}, 3,
62 'parsed three entries');
63 is($t->{feed}->{id}, 'mailto:v1@example.com',
64 'id is set to default');
67 like($feed, qr/drop me/, "long quoted text kept");
68 like($feed, qr/inline me here/, "short quoted text kept");
69 like($feed, qr/keep me/, "unquoted text saved");
72 # add a new spam message
75 $spam = PublicInbox::Eml->new(<<EOF);
76 From: SPAMMER <spammer\@example.com>
77 To: U <u\@example.com>
78 Message-Id: <this-is-spam\@example.com>
80 Date: Thu, 01 Jan 1970 00:00:00 +0000
89 my $spammy_feed = string_feed({ ibx => $ibx });
91 skip 'XML::TreePP missing', 2 unless $have_xml_treepp;
92 my $t = XML::TreePP->new->parse($spammy_feed);
93 like($t->{feed}->{-xmlns}, qr/\bAtom\b/,
94 'looks like an an Atom feed');
95 is(scalar @{$t->{feed}->{entry}}, 3,
96 'parsed three entries');
98 like($spammy_feed, qr/SPAM/s, "spam showed up :<");
105 # spam no longer shows up
107 my $feed = string_feed({ ibx => $ibx });
109 skip 'XML::TreePP missing', 2 unless $have_xml_treepp;
110 my $t = XML::TreePP->new->parse($feed);
111 like($t->{feed}->{-xmlns}, qr/\bAtom\b/,
112 'looks like an an Atom feed');
113 is(scalar @{$t->{feed}->{entry}}, 3,
114 'parsed three entries');
116 unlike($feed, qr/SPAM/, "spam gone :>");