NAME

Mail::Make::Headers::ContentDisposition - Content-Disposition Header Field Object

SYNOPSIS

use Mail::Make::Headers::ContentDisposition;

my $cd = Mail::Make::Headers::ContentDisposition->new( 'inline' ) ||
    die( Mail::Make::Headers::ContentDisposition->error );
$cd->filename( 'Yamato,Inc-Logo.png' );
print "$cd";
# inline; filename*=UTF-8''Yamato%2CInc-Logo.png

# Pure ASCII filename — plain quoting used instead
$cd->filename( 'logo.png' );
print "$cd";
# inline; filename="logo.png"

# With language hint for RFC 2231
$cd->filename( 'ファイル.txt', 'ja-JP' );
print "$cd";
# inline; filename*=UTF-8'ja-JP'%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB.txt

VERSION

v0.1.0

DESCRIPTION

Typed object for the Content-Disposition mail header field.

The key improvement over MIME::Entity / Mail::Field is the "filename" method: when the filename contains special RFC 2045 characters (including commas) or non-ASCII characters, it automatically encodes the value using RFC 2231 extended notation (filename*), instead of silently producing a malformed header that corrupts the entire message.

METHODS

new( $disposition [, %params ] )

Instantiates a new object. $disposition must be one of inline, attachment, or form-data.

as_string

Returns the complete header field value as a string, including all parameters.

disposition( [ $disposition ] )

Sets or gets the disposition type. Validates that the value is one of inline, attachment, or form-data. Returns an error otherwise.

filename( [ $filename [, $language ] ] )

Sets or gets the filename parameter. This method is RFC 2231 aware:

  • If $filename contains non-ASCII characters or RFC 2045 special characters (such as ,, (, ), @, etc.), it encodes the value as filename*=UTF-8'language'percent-encoded and sets filename* instead of filename.

  • Otherwise, the filename is stored as a plain quoted filename= parameter.

  • On retrieval, filename* takes precedence over filename. The value is decoded and returned as a plain Perl string.

Setting to undef removes both filename and filename*.

filename_charset

Returns the charset used during the last RFC 2231 decode operation. Set automatically by "filename". Read-only in normal usage; only utf-8 is accepted if set explicitly.

filename_lang

Sets or gets the default language tag (RFC 1766 / ISO 639) used when encoding filenames with RFC 2231. For example ja-JP.

name( [ $name ] )

Sets or gets the name= parameter, used for form-data dispositions.

param( $name [, $value ] )

Low-level access to an arbitrary parameter.

params( $name => $value, ... )

Sets multiple parameters at once. With no arguments, returns the parameter hash object.

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Mail::Make, Mail::Make::Headers, Mail::Make::Headers::Generic, Mail::Make::Headers::ContentType

RFC 2183, RFC 2231, RFC 5987

COPYRIGHT & LICENSE

Copyright(c) 2026 DEGUEST Pte. Ltd.

All rights reserved.

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