1Email::MIME::ContentTypUes(e3r)Contributed Perl DocumentEamtaiioln::MIME::ContentType(3)
2
3
4

NAME

6       Email::MIME::ContentType - Parse and build a MIME Content-Type or
7       Content-Disposition Header
8

VERSION

10       version 1.026
11

SYNOPSIS

13         use Email::MIME::ContentType;
14
15         # Content-Type: text/plain; charset="us-ascii"; format=flowed
16         my $ct = 'text/plain; charset="us-ascii"; format=flowed';
17         my $data = parse_content_type($ct);
18
19         $data = {
20           type       => "text",
21           subtype    => "plain",
22           attributes => {
23             charset => "us-ascii",
24             format  => "flowed"
25           }
26         };
27
28         my $ct_new = build_content_type($data);
29         # text/plain; charset=us-ascii; format=flowed
30
31
32         # Content-Type: application/x-stuff;
33         #  title*0*=us-ascii'en'This%20is%20even%20more%20;
34         #  title*1*=%2A%2A%2Afun%2A%2A%2A%20;
35         #  title*2="isn't it!"
36         my $ct = q(application/x-stuff;
37          title*0*=us-ascii'en'This%20is%20even%20more%20;
38          title*1*=%2A%2A%2Afun%2A%2A%2A%20;
39          title*2="isn't it!");
40         my $data = parse_content_type($ct);
41
42         $data = {
43           type       => "application",
44           subtype    => "x-stuff",
45           attributes => {
46             title => "This is even more ***fun*** isn't it!"
47           }
48         };
49
50
51         # Content-Disposition: attachment; filename=genome.jpeg;
52         #   modification-date="Wed, 12 Feb 1997 16:29:51 -0500"
53         my $cd = q(attachment; filename=genome.jpeg;
54           modification-date="Wed, 12 Feb 1997 16:29:51 -0500");
55         my $data = parse_content_disposition($cd);
56
57         $data = {
58           type       => "attachment",
59           attributes => {
60             filename            => "genome.jpeg",
61             "modification-date" => "Wed, 12 Feb 1997 16:29:51 -0500"
62           }
63         };
64
65         my $cd_new = build_content_disposition($data);
66         # attachment; filename=genome.jpeg; modification-date="Wed, 12 Feb 1997 16:29:51 -0500"
67

FUNCTIONS

69   parse_content_type
70       This routine is exported by default.
71
72       This routine parses email content type headers according to section 5.1
73       of RFC 2045 and also RFC 2231 (Character Set and Parameter
74       Continuations).  It returns a hash as above, with entries for the
75       "type", the "subtype", and a hash of "attributes".
76
77       For backward compatibility with a really unfortunate misunderstanding
78       of RFC 2045 by the early implementors of this module, "discrete" and
79       "composite" are also present in the returned hashref, with the values
80       of "type" and "subtype" respectively.
81
82   parse_content_disposition
83       This routine is exported by default.
84
85       This routine parses email Content-Disposition headers according to RFC
86       2183 and RFC 2231.  It returns a hash as above, with entries for the
87       "type", and a hash of "attributes".
88
89   build_content_type
90       This routine is exported by default.
91
92       This routine builds email Content-Type header according to RFC 2045 and
93       RFC 2231.  It takes a hash as above, with entries for the "type", the
94       "subtype", and optionally also a hash of "attributes".  It returns a
95       string representing Content-Type header.  Non-ASCII attributes are
96       encoded to UTF-8 according to Character Set section of RFC 2231.
97       Attribute which has more then 78 ASCII characters is split into more
98       attributes accorrding to Parameter Continuations of RFC 2231.  For
99       compatibility reasons with clients which do not support RFC 2231,
100       output string contains also truncated ASCII version of any too long or
101       non-ASCII attribute.  Encoding to ASCII is done via Text::Unidecode
102       module.
103
104   build_content_disposition
105       This routine is exported by default.
106
107       This routine builds email Content-Disposition header according to RFC
108       2182 and RFC 2231.  It takes a hash as above, with entries for the
109       "type", and optionally also a hash of "attributes".  It returns a
110       string representing Content-Disposition header.  Non-ASCII or too long
111       attributes are handled in the same way like in build_content_type
112       function.
113

WARNINGS

115       This is not a valid content-type header, according to both RFC 1521 and
116       RFC 2045:
117
118         Content-Type: type/subtype;
119
120       If a semicolon appears, a parameter must.  "parse_content_type" will
121       carp if it encounters a header of this type, but you can suppress this
122       by setting $Email::MIME::ContentType::STRICT_PARAMS to a false value.
123       Please consider localizing this assignment!
124
125       Same applies for "parse_content_disposition".
126

AUTHORS

128       •   Simon Cozens <simon@cpan.org>
129
130       •   Casey West <casey@geeknest.com>
131
132       •   Ricardo SIGNES <rjbs@cpan.org>
133

CONTRIBUTORS

135       •   Matthew Green <mrg@eterna.com.au>
136
137       •   Pali <pali@cpan.org>
138
139       •   Ricardo Signes <rjbs@semiotic.systems>
140
141       •   Thomas Szukala <ts@abusix.com>
142
144       This software is copyright (c) 2004 by Simon Cozens.
145
146       This is free software; you can redistribute it and/or modify it under
147       the same terms as the Perl 5 programming language system itself.
148
149
150
151perl v5.32.1                      2021-01-27       Email::MIME::ContentType(3)
Impressum