diff options
author | Eric Wong <e@80x24.org> | 2017-01-26 02:09:36 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-01-26 03:22:54 +0000 |
commit | 7e40887e8d2bef4126b4a3680594860a3b2fd67c (patch) | |
tree | 222b7fbbf7457eac086b193384bf7de3dbb08ce4 /t | |
parent | a465cc132b8d1ad96dbd0f51ad6da2ce75c79568 (diff) | |
download | public-inbox-7e40887e8d2bef4126b4a3680594860a3b2fd67c.tar.gz |
Some mailing lists add annoying tags into the Subject line which discourages readers from doing proper mail organization on the client side. They also waste precious screen space and attention span. Remove them from our archives to reduce clutter.
Diffstat (limited to 't')
-rw-r--r-- | t/filter_subjecttag.t | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/t/filter_subjecttag.t b/t/filter_subjecttag.t new file mode 100644 index 00000000..54a219e7 --- /dev/null +++ b/t/filter_subjecttag.t @@ -0,0 +1,27 @@ +# Copyright (C) 2017 all contributors <meta@public-inbox.org> +# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> +use strict; +use warnings; +use Test::More; +use Email::MIME; +use_ok 'PublicInbox::Filter::SubjectTag'; + +my $f = eval { PublicInbox::Filter::SubjectTag->new }; +like($@, qr/tag not defined/, 'error without args'); +$f = PublicInbox::Filter::SubjectTag->new('-tag', '[foo]'); +is(ref $f, 'PublicInbox::Filter::SubjectTag', 'new object created'); + +my $mime = Email::MIME->new(<<EOF); +To: you <you\@example.com> +Subject: =?UTF-8?B?UmU6IFtmb29dIEVsw4PCqWFub3I=?= + +EOF + +$mime = $f->delivery($mime); +is($mime->header('Subject'), "Re: El\xc3\xa9anor", 'filtered with Re:'); + +$mime->header_str_set('Subject', '[FOO] bar'); +$mime = $f->delivery($mime); +is($mime->header('Subject'), 'bar', 'filtered non-reply'); + +done_testing(); |