1 # Copyright (C) 2017-2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use_ok 'PublicInbox::Hval', qw(from_attr to_attr);
9 -no_obfuscate_re => qr/(?:example\.com)\z/i,
11 'meta@public-inbox.org' => 1,
24 PublicInbox::Hval::obfuscate_addrs($ibx, $html);
27 hello@example•comm
30 test@public-inbox•org
32 te.st@example•org
35 is($html, $exp, 'only obfuscated relevant addresses');
37 is('foo-bar', PublicInbox::Hval::to_filename('foo bar '),
38 'to_filename has no trailing -');
40 is('foo-bar', PublicInbox::Hval::to_filename("foo bar\nanother line\n"),
41 'to_filename has no repeated -, and nothing past LF');
43 is('foo.bar', PublicInbox::Hval::to_filename("foo....bar"),
44 'to_filename squeezes -');
47 PublicInbox::Hval::src_escape($s);
48 is($s, "\\0\\a\n", 'src_escape works as intended');
50 foreach my $s ('Hello/World.pm', 'Zcat', 'hello world.c', 'Eléanor', '$at') {
51 my $attr = to_attr($s);
52 is(from_attr($attr), $s, "$s => $attr => $s round trips");
56 my $bad = to_attr('foo//bar');
57 ok(!$bad, 'double-slash rejected');