Provided by: libemail-mime-contenttype-perl_1.026-1_all bug

NAME

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

VERSION

       version 1.026

SYNOPSIS

         use Email::MIME::ContentType;

         # Content-Type: text/plain; charset="us-ascii"; format=flowed
         my $ct = 'text/plain; charset="us-ascii"; format=flowed';
         my $data = parse_content_type($ct);

         $data = {
           type       => "text",
           subtype    => "plain",
           attributes => {
             charset => "us-ascii",
             format  => "flowed"
           }
         };

         my $ct_new = build_content_type($data);
         # text/plain; charset=us-ascii; format=flowed

         # Content-Type: application/x-stuff;
         #  title*0*=us-ascii'en'This%20is%20even%20more%20;
         #  title*1*=%2A%2A%2Afun%2A%2A%2A%20;
         #  title*2="isn't it!"
         my $ct = q(application/x-stuff;
          title*0*=us-ascii'en'This%20is%20even%20more%20;
          title*1*=%2A%2A%2Afun%2A%2A%2A%20;
          title*2="isn't it!");
         my $data = parse_content_type($ct);

         $data = {
           type       => "application",
           subtype    => "x-stuff",
           attributes => {
             title => "This is even more ***fun*** isn't it!"
           }
         };

         # Content-Disposition: attachment; filename=genome.jpeg;
         #   modification-date="Wed, 12 Feb 1997 16:29:51 -0500"
         my $cd = q(attachment; filename=genome.jpeg;
           modification-date="Wed, 12 Feb 1997 16:29:51 -0500");
         my $data = parse_content_disposition($cd);

         $data = {
           type       => "attachment",
           attributes => {
             filename            => "genome.jpeg",
             "modification-date" => "Wed, 12 Feb 1997 16:29:51 -0500"
           }
         };

         my $cd_new = build_content_disposition($data);
         # attachment; filename=genome.jpeg; modification-date="Wed, 12 Feb 1997 16:29:51 -0500"

FUNCTIONS

   parse_content_type
       This routine is exported by default.

       This routine parses email content type headers according to section 5.1 of RFC 2045 and also RFC 2231
       (Character Set and Parameter Continuations).  It returns a hash as above, with entries for the "type",
       the "subtype", and a hash of "attributes".

       For backward compatibility with a really unfortunate misunderstanding of RFC 2045 by the early
       implementors of this module, "discrete" and "composite" are also present in the returned hashref, with
       the values of "type" and "subtype" respectively.

   parse_content_disposition
       This routine is exported by default.

       This routine parses email Content-Disposition headers according to RFC 2183 and RFC 2231.  It returns a
       hash as above, with entries for the "type", and a hash of "attributes".

   build_content_type
       This routine is exported by default.

       This routine builds email Content-Type header according to RFC 2045 and RFC 2231.  It takes a hash as
       above, with entries for the "type", the "subtype", and optionally also a hash of "attributes".  It
       returns a string representing Content-Type header.  Non-ASCII attributes are encoded to UTF-8 according
       to Character Set section of RFC 2231.  Attribute which has more then 78 ASCII characters is split into
       more attributes accorrding to Parameter Continuations of RFC 2231.  For compatibility reasons with
       clients which do not support RFC 2231, output string contains also truncated ASCII version of any too
       long or non-ASCII attribute.  Encoding to ASCII is done via Text::Unidecode module.

   build_content_disposition
       This routine is exported by default.

       This routine builds email Content-Disposition header according to RFC 2182 and RFC 2231.  It takes a hash
       as above, with entries for the "type", and optionally also a hash of "attributes".  It returns a string
       representing Content-Disposition header.  Non-ASCII or too long attributes are handled in the same way
       like in build_content_type function.

WARNINGS

       This is not a valid content-type header, according to both RFC 1521 and RFC 2045:

         Content-Type: type/subtype;

       If a semicolon appears, a parameter must.  "parse_content_type" will carp if it encounters a header of
       this type, but you can suppress this by setting $Email::MIME::ContentType::STRICT_PARAMS to a false
       value.  Please consider localizing this assignment!

       Same applies for "parse_content_disposition".

AUTHORS

       •   Simon Cozens <simon@cpan.org>

       •   Casey West <casey@geeknest.com>

       •   Ricardo SIGNES <rjbs@cpan.org>

CONTRIBUTORS

       •   Matthew Green <mrg@eterna.com.au>

       •   Pali <pali@cpan.org>

       •   Ricardo Signes <rjbs@semiotic.systems>

       •   Thomas Szukala <ts@abusix.com>

COPYRIGHT AND LICENSE

       This software is copyright (c) 2004 by Simon Cozens.

       This  is  free  software;  you  can  redistribute  it and/or modify it under the same terms as the Perl 5
       programming language system itself.

perl v5.32.0                                       2021-01-12                      Email::MIME::ContentType(3pm)