1Email::MIME::ContentTypUes(e3r)Contributed Perl DocumentEamtaiioln::MIME::ContentType(3)
2
3
4
6 Email::MIME::ContentType - Parse a MIME Content-Type or
7 Content-Disposition Header
8
10 version 1.022
11
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
29 # Content-Type: application/x-stuff;
30 # title*0*=us-ascii'en'This%20is%20even%20more%20;
31 # title*1*=%2A%2A%2Afun%2A%2A%2A%20;
32 # title*2="isn't it!"
33 my $ct = q(application/x-stuff;
34 title*0*=us-ascii'en'This%20is%20even%20more%20;
35 title*1*=%2A%2A%2Afun%2A%2A%2A%20;
36 title*2="isn't it!");
37 my $data = parse_content_type($ct);
38
39 $data = {
40 type => "application",
41 subtype => "x-stuff",
42 attributes => {
43 title => "This is even more ***fun*** isn't it!"
44 }
45 };
46
47 # Content-Disposition: attachment; filename=genome.jpeg;
48 # modification-date="Wed, 12 Feb 1997 16:29:51 -0500"
49 my $cd = q(attachment; filename=genome.jpeg;
50 modification-date="Wed, 12 Feb 1997 16:29:51 -0500");
51 my $data = parse_content_disposition($cd);
52
53 $data = {
54 type => "attachment",
55 attributes => {
56 filename => "genome.jpeg",
57 "modification-date" => "Wed, 12 Feb 1997 16:29:51 -0500"
58 }
59 };
60
62 parse_content_type
63 This routine is exported by default.
64
65 This routine parses email content type headers according to section 5.1
66 of RFC 2045 and also RFC 2231 (Character Set and Parameter
67 Continuations). It returns a hash as above, with entries for the
68 "type", the "subtype", and a hash of "attributes".
69
70 For backward compatibility with a really unfortunate misunderstanding
71 of RFC 2045 by the early implementors of this module, "discrete" and
72 "composite" are also present in the returned hashref, with the values
73 of "type" and "subtype" respectively.
74
75 parse_content_disposition
76 This routine is exported by default.
77
78 This routine parses email Content-Disposition headers according to RFC
79 2183 and RFC 2231. It returns a hash as above, with entries for the
80 "type", and a hash of "attributes".
81
83 This is not a valid content-type header, according to both RFC 1521 and
84 RFC 2045:
85
86 Content-Type: type/subtype;
87
88 If a semicolon appears, a parameter must. "parse_content_type" will
89 carp if it encounters a header of this type, but you can suppress this
90 by setting $Email::MIME::ContentType::STRICT_PARAMS to a false value.
91 Please consider localizing this assignment!
92
93 Same applies for "parse_content_disposition".
94
96 · Simon Cozens <simon@cpan.org>
97
98 · Casey West <casey@geeknest.com>
99
100 · Ricardo SIGNES <rjbs@cpan.org>
101
103 · Matthew Green <mrg@eterna.com.au>
104
105 · Pali <pali@cpan.org>
106
107 · Thomas Szukala <ts@abusix.com>
108
110 This software is copyright (c) 2004 by Simon Cozens.
111
112 This is free software; you can redistribute it and/or modify it under
113 the same terms as the Perl 5 programming language system itself.
114
115
116
117perl v5.28.0 2017-08-31 Email::MIME::ContentType(3)