2 # Copyright (C) all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # corner cases to abuse URL-fication
5 use v5.12; use PublicInbox::TestCommon;
7 use PublicInbox::IO qw(write_file);
8 require_mods(qw(DBD::SQLite Xapian psgi -httpd));
9 require PublicInbox::Eml;
10 require PublicInbox::WWW;
12 my $ibx_a = create_inbox 'a', indexlevel => 'basic', sub {
14 $im->add(PublicInbox::Eml->new(<<EOM)) or xbail;
15 Date: Fri, 02 Oct 1993 00:00:04 +0000
17 Message-ID: <xpost-addr-urlfic\@tion>
18 To: <$ibx->{-primary_address}>
19 Cc: <;>, <"foo>">, <amp&\@wtf>, <gt>, "<", ">", <lt>,
20 somethingelse\@example.com
24 my $ibx_b = create_inbox 'b', indexlevel => 'basic', sub {
26 $im->add(PublicInbox::Eml->new(<<EOM)) or xbail;
27 Date: Fri, 02 Oct 1993 00:00:00 +0000
28 Message-ID: <wh\@tever>
30 To: <$ibx->{-primary_address}>
31 Cc: <$ibx_a->{-primary_address}>
36 my $cfgpath = "$tmpdir/public-inbox.config";
38 write_file '>', $cfgpath, <<EOM;
42 inboxdir = $ibx_a->{inboxdir}
43 address = $ibx_a->{-primary_address}
44 address = somethingelse\@example.com
46 inboxdir = $ibx_b->{inboxdir}
47 address = $ibx_b->{-primary_address}
54 my $cfg = PublicInbox::Config->new($cfgpath);
55 my $www = PublicInbox::WWW->new($cfg);
56 my $env = { TMPDIR => "$tmpdir", PI_CONFIG => $cfgpath };
59 my $res = $cb->(GET('/a/xpost-addr-urlfic@tion/'));
60 my $content = $res->content;
61 for my $c ('&', ';', '<', '>') {
62 unlike $content, qr/>$c</s, "no bare `$c' from URL-ification";
64 like $content, qr/>somethingelse\@example\.com</s,
68 test_psgi(sub { $www->call(@_) }, $client);
69 test_httpd $env, $client;