line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 1999-2022 by [Mark Overmeer ]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.03. |
5
|
|
|
|
|
|
|
# This code is part of distribution MIME::Types. Meta-POD processed with |
6
|
|
|
|
|
|
|
# OODoc into POD and HTML manual-pages. See README.md |
7
|
|
|
|
|
|
|
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package MIME::Type; |
10
|
6
|
|
|
6
|
|
137071
|
use vars '$VERSION'; |
|
6
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
310
|
|
11
|
|
|
|
|
|
|
$VERSION = '2.24'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
|
33
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
123
|
|
15
|
|
|
|
|
|
|
|
16
|
6
|
|
|
6
|
|
24
|
use Carp 'croak'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
322
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#------------------------------------------- |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use overload |
23
|
6
|
|
|
|
|
35
|
'""' => 'type' |
24
|
6
|
|
|
6
|
|
6997
|
, cmp => 'cmp'; |
|
6
|
|
|
|
|
6081
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#------------------------------------------- |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
2094
|
|
|
2094
|
1
|
8559
|
sub new(@) { (bless {}, shift)->init( {@_} ) } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub init($) |
32
|
2094
|
|
|
2094
|
0
|
3331
|
{ my ($self, $args) = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $type = $self->{MT_type} = $args->{type} |
35
|
2094
|
50
|
|
|
|
5794
|
or croak "ERROR: Type parameter is obligatory."; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->{MT_simplified} = $args->{simplified} |
38
|
2094
|
|
66
|
|
|
4780
|
|| $self->simplified($type); |
39
|
|
|
|
|
|
|
|
40
|
2094
|
|
100
|
|
|
4933
|
$self->{MT_extensions} = $args->{extensions} || []; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$self->{MT_encoding} |
43
|
|
|
|
|
|
|
= $args->{encoding} ? $args->{encoding} |
44
|
2094
|
100
|
|
|
|
4112
|
: $self->mediaType eq 'text' ? 'quoted-printable' |
|
|
100
|
|
|
|
|
|
45
|
|
|
|
|
|
|
: 'base64'; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$self->{MT_system} = $args->{system} |
48
|
2094
|
50
|
|
|
|
4418
|
if defined $args->{system}; |
49
|
|
|
|
|
|
|
|
50
|
2094
|
|
|
|
|
9523
|
$self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#------------------------------------------- |
54
|
|
|
|
|
|
|
|
55
|
16550
|
|
|
16550
|
1
|
40449
|
sub type() {shift->{MT_type}} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub simplified(;$) |
59
|
2181
|
|
|
2181
|
1
|
2739
|
{ my $thing = shift; |
60
|
2181
|
100
|
|
|
|
3728
|
return $thing->{MT_simplified} unless @_; |
61
|
|
|
|
|
|
|
|
62
|
2126
|
|
|
|
|
2666
|
my $mime = shift; |
63
|
|
|
|
|
|
|
|
64
|
2126
|
50
|
|
|
|
17896
|
$mime =~ m!^\s*(?:x\-)?([\w.+-]+)/(?:x\-)?([\w.+-]+)\s*$!i ? lc "$1/$2" |
|
|
100
|
|
|
|
|
|
65
|
|
|
|
|
|
|
: $mime eq 'text' ? 'text/plain' # some silly mailers... |
66
|
|
|
|
|
|
|
: undef; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
4132
|
|
|
4132
|
1
|
4592
|
sub extensions() { @{shift->{MT_extensions}} } |
|
4132
|
|
|
|
|
8899
|
|
71
|
4099
|
|
|
4099
|
1
|
13549
|
sub encoding() {shift->{MT_encoding}} |
72
|
0
|
|
|
0
|
1
|
0
|
sub system() {shift->{MT_system}} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#------------------------------------------- |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
1994
|
100
|
|
1994
|
1
|
8889
|
sub mediaType() {shift->{MT_simplified} =~ m!^([\w.-]+)/! ? $1 : undef} |
78
|
2
|
|
|
2
|
0
|
6
|
sub mainType() {shift->mediaType} # Backwards compatibility |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
2
|
50
|
|
2
|
1
|
23
|
sub subType() {shift->{MT_simplified} =~ m!/([\w+.-]+)$! ? $1 : undef} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
8
|
|
|
8
|
1
|
68
|
sub isRegistered() { lc shift->{MT_type} !~ m{^x\-|/x\-} } |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# http://tools.ietf.org/html/rfc4288#section-3 |
88
|
4
|
|
|
4
|
1
|
30
|
sub isVendor() {shift->{MT_simplified} =~ m!/vnd\.!} |
89
|
4
|
|
|
4
|
1
|
24
|
sub isPersonal() {shift->{MT_simplified} =~ m!/prs\.!} |
90
|
4
|
|
|
4
|
1
|
25
|
sub isExperimental() {shift->{MT_simplified} =~ m!/x\.! } |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
4
|
|
|
4
|
1
|
402
|
sub isBinary() { shift->{MT_encoding} eq 'base64' } |
94
|
4
|
|
|
4
|
1
|
22
|
sub isText() { shift->{MT_encoding} ne 'base64' } |
95
|
|
|
|
|
|
|
*isAscii = \&isText; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# simplified names only! |
99
|
|
|
|
|
|
|
my %sigs = map +($_ => 1), |
100
|
|
|
|
|
|
|
qw(application/pgp-keys application/pgp application/pgp-signature |
101
|
|
|
|
|
|
|
application/pkcs10 application/pkcs7-mime application/pkcs7-signature |
102
|
|
|
|
|
|
|
text/vCard); |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
0
|
1
|
0
|
sub isSignature() { $sigs{shift->{MT_simplified}} } |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub cmp($) |
108
|
37
|
|
|
37
|
0
|
1659
|
{ my ($self, $other) = @_; |
109
|
|
|
|
|
|
|
|
110
|
37
|
100
|
|
|
|
109
|
my $type = ref $other |
111
|
|
|
|
|
|
|
? $other->simplified |
112
|
|
|
|
|
|
|
: (ref $self)->simplified($other); |
113
|
|
|
|
|
|
|
|
114
|
37
|
|
|
|
|
72
|
$self->simplified cmp $type; |
115
|
|
|
|
|
|
|
} |
116
|
19
|
|
|
19
|
1
|
1732
|
sub equals($) { $_[0]->cmp($_[1])==0 } |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |