]>
git.proxmox.com Git - pmg-api.git/blob - src/PMG/RuleDB/ContentTypeFilter.pm
1 package PMG
::RuleDB
::ContentTypeFilter
;
10 use PMG
::RuleDB
::MatchField
;
12 use base
qw(PMG::RuleDB::MatchField);
15 'application/x-msdos-program' => 'application/x-ms-dos-executable',
16 'application/java-vm' => 'application/x-java',
17 'application/x-javascript' => 'application/javascript',
25 return 'ContentType Filter';
29 my ($type, $fvalue, $ogroup) = @_;
31 my $class = ref($type) || $type;
33 # translate old values
34 if ($fvalue && (my $nt = $oldtypemap->{$fvalue})) {
38 my $self = $class->SUPER::new
('content-type', $fvalue, $ogroup);
44 my ($type, $ruledb, $id, $ogroup, $value) = @_;
46 my $class = ref($type) || $type;
48 my $obj = $class->SUPER::load_attr
($ruledb, $id, $ogroup, $value);
50 # translate old values
51 if ($obj->{field_value
} && (my $nt = $oldtypemap->{$obj->{field_value
}})) {
52 $obj->{field_value
} = $nt;
59 my ($self, $entity) = @_;
63 # match subtypes? We currently do exact matches only.
65 if (my $id = $entity->head->mime_attr ('x-proxmox-tmp-aid')) {
68 my $header_ct = $entity->head->mime_attr ('content-type');
70 my $magic_ct = $entity->{PMX_magic_ct
};
72 my $glob_ct = $entity->{PMX_glob_ct
};
74 if ($header_ct && $header_ct =~ m
|$self->{field_value
}|) {
76 } elsif ($magic_ct && $magic_ct =~ m
|$self->{field_value
}|) {
78 } elsif ($glob_ct && $glob_ct =~ m
|$self->{field_value
}|) {
83 foreach my $part ($entity->parts) {
84 if (my $match = $self->parse_entity ($part)) {
93 my ($self, $queue, $entity, $msginfo) = @_;
95 return $self->parse_entity ($entity);
103 description
=> "Content Type",
105 pattern
=> '[0-9a-zA-Z\/\\\[\]\+\-\.\*\_]+',
114 return { contenttype
=> $self->{field_value
} };
118 my ($self, $param) = @_;
120 $self->{field_value
} = $param->{contenttype
};
127 =head1 PMG::RuleDB::ContentTypeFilter