2 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
3 # Copyright (C) 2004- Simon Cozens, Casey West, Ricardo SIGNES
4 # This library is free software; you can redistribute it and/or modify
5 # it under the same terms as Perl itself.
7 # License: GPL-1.0+ or Artistic-1.0-Perl
8 # <https://www.gnu.org/licenses/gpl-1.0.txt>
9 # <https://dev.perl.org/licenses/artistic.html>
12 use PublicInbox::EmlContentFoo qw(parse_content_disposition);
15 '' => { type => 'attachment', attributes => {} },
16 'inline' => { type => 'inline', attributes => {} },
17 'attachment' => { type => 'attachment', attributes => {} },
19 'attachment; filename=genome.jpeg;' .
20 ' modification-date="Wed, 12 Feb 1997 16:29:51 -0500"' => {
23 filename => 'genome.jpeg',
24 'modification-date' => 'Wed, 12 Feb 1997 16:29:51 -0500'
28 q(attachment; filename*=UTF-8''genome.jpeg;) .
29 q( modification-date="Wed, 12 Feb 1997 16:29:51 -0500") => {
32 filename => 'genome.jpeg',
33 'modification-date' => 'Wed, 12 Feb 1997 16:29:51 -0500'
37 q(attachment; filename*0*=us-ascii'en'This%20is%20even%20more%20;) .
38 q( filename*1*=%2A%2A%2Afun%2A%2A%2A%20; filename*2="isn't it!") => {
41 filename => "This is even more ***fun*** isn't it!"
45 q(attachment; filename*0*='en'This%20is%20even%20more%20;) .
46 q( filename*1*=%2A%2A%2Afun%2A%2A%2A%20; filename*2="isn't it!") => {
49 filename => "This is even more ***fun*** isn't it!"
53 q(attachment; filename*0*=''This%20is%20even%20more%20;) .
54 q( filename*1*=%2A%2A%2Afun%2A%2A%2A%20; filename*2="isn't it!") => {
57 filename => "This is even more ***fun*** isn't it!"
61 q(attachment; filename*0*=us-ascii''This%20is%20even%20more%20;).
62 q( filename*1*=%2A%2A%2Afun%2A%2A%2A%20; filename*2="isn't it!") => {
65 filename => "This is even more ***fun*** isn't it!"
70 my %non_strict_cd_tests = (
71 'attachment; filename=genome.jpeg;' .
72 ' modification-date="Wed, 12 Feb 1997 16:29:51 -0500";' => {
75 filename => 'genome.jpeg',
76 'modification-date' =>
77 'Wed, 12 Feb 1997 16:29:51 -0500'
83 my ($string, $expect, $info) = @_;
87 is_deeply(parse_content_disposition($string), $expect, $info);
90 for (sort keys %cd_tests) {
91 test($_, $cd_tests{$_}, "Can parse C-D <$_>");
94 local $PublicInbox::EmlContentFoo::STRICT_PARAMS = 0;
95 for (sort keys %cd_tests) {
96 test($_, $cd_tests{$_}, "Can parse non-strict C-D <$_>");
98 for (sort keys %non_strict_cd_tests) {
99 test($_, $non_strict_cd_tests{$_}, "Can parse non-strict C-D <$_>");