Server IP : 85.214.239.14 / Your IP : 18.226.165.234 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/cwd/proc/2/root/proc/2/cwd/proc/3/root/proc/2/cwd/usr/share/perl5/MIME/ |
Upload File : |
# Copyrights 1999-2022 by [Mark Overmeer <markov@cpan.org>]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.03. # This code is part of distribution MIME::Types. Meta-POD processed with # OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package MIME::Type; use vars '$VERSION'; $VERSION = '2.24'; use strict; use Carp 'croak'; #------------------------------------------- use overload '""' => 'type' , cmp => 'cmp'; #------------------------------------------- sub new(@) { (bless {}, shift)->init( {@_} ) } sub init($) { my ($self, $args) = @_; my $type = $self->{MT_type} = $args->{type} or croak "ERROR: Type parameter is obligatory."; $self->{MT_simplified} = $args->{simplified} || $self->simplified($type); $self->{MT_extensions} = $args->{extensions} || []; $self->{MT_encoding} = $args->{encoding} ? $args->{encoding} : $self->mediaType eq 'text' ? 'quoted-printable' : 'base64'; $self->{MT_system} = $args->{system} if defined $args->{system}; $self; } #------------------------------------------- sub type() {shift->{MT_type}} sub simplified(;$) { my $thing = shift; return $thing->{MT_simplified} unless @_; my $mime = shift; $mime =~ m!^\s*(?:x\-)?([\w.+-]+)/(?:x\-)?([\w.+-]+)\s*$!i ? lc "$1/$2" : $mime eq 'text' ? 'text/plain' # some silly mailers... : undef; } sub extensions() { @{shift->{MT_extensions}} } sub encoding() {shift->{MT_encoding}} sub system() {shift->{MT_system}} #------------------------------------------- sub mediaType() {shift->{MT_simplified} =~ m!^([\w.-]+)/! ? $1 : undef} sub mainType() {shift->mediaType} # Backwards compatibility sub subType() {shift->{MT_simplified} =~ m!/([\w+.-]+)$! ? $1 : undef} sub isRegistered() { lc shift->{MT_type} !~ m{^x\-|/x\-} } # http://tools.ietf.org/html/rfc4288#section-3 sub isVendor() {shift->{MT_simplified} =~ m!/vnd\.!} sub isPersonal() {shift->{MT_simplified} =~ m!/prs\.!} sub isExperimental() {shift->{MT_simplified} =~ m!/x\.! } sub isBinary() { shift->{MT_encoding} eq 'base64' } sub isText() { shift->{MT_encoding} ne 'base64' } *isAscii = \&isText; # simplified names only! my %sigs = map +($_ => 1), qw(application/pgp-keys application/pgp application/pgp-signature application/pkcs10 application/pkcs7-mime application/pkcs7-signature text/vCard); sub isSignature() { $sigs{shift->{MT_simplified}} } sub cmp($) { my ($self, $other) = @_; my $type = ref $other ? $other->simplified : (ref $self)->simplified($other); $self->simplified cmp $type; } sub equals($) { $_[0]->cmp($_[1])==0 } 1;