fix: Mail::Get now handles multipart/alternative messages appropriately. This fixes CS posts showing multiple versions when e-mailed in.
This commit is contained in:
parent
c24e711e42
commit
cdc6671929
2 changed files with 43 additions and 9 deletions
|
|
@ -14,7 +14,10 @@
|
||||||
- fix: XSS vulnerability in Wiki Page titles.
|
- fix: XSS vulnerability in Wiki Page titles.
|
||||||
- Removed the requirement for DBIx::FullTextSearch from testEnvironment.pl
|
- Removed the requirement for DBIx::FullTextSearch from testEnvironment.pl
|
||||||
since it hasn't been needed since 6.5. It was just never removed.
|
since it hasn't been needed since 6.5. It was just never removed.
|
||||||
|
- fix: WebGUI::Mail::Get now handles multipart/alternative messages
|
||||||
|
appropriately. This fixes the problem with CS posts sent via
|
||||||
|
e-mail showing two versions of the same post.
|
||||||
|
|
||||||
7.3.3
|
7.3.3
|
||||||
- fix: Wiki Purge throws fatal
|
- fix: Wiki Purge throws fatal
|
||||||
- fix: Calendar now reports proper product ID on iCal feed
|
- fix: Calendar now reports proper product ID on iCal feed
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,16 @@ Retrieves the next available message from the server. Returns undef if there are
|
||||||
type=>'application/msword',
|
type=>'application/msword',
|
||||||
content=>' ---- binary content here ---- ',
|
content=>' ---- binary content here ---- ',
|
||||||
filename => undef
|
filename => undef
|
||||||
}
|
alternative => [
|
||||||
|
{
|
||||||
|
type => 'text/html',
|
||||||
|
content => '---- alternative content for msword doc here ---- ',
|
||||||
|
},{
|
||||||
|
type => 'text/plain',
|
||||||
|
content => '---- even more alternative content for msword doc ---- ',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,7 +161,9 @@ sub getNextMessage {
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
my $head = $parsedMessage->head;
|
my $head = $parsedMessage->head;
|
||||||
# try to detect auto generated messages and drop them
|
my $type = $head->get("Content-Type");
|
||||||
|
my $alternate = 1 if lc $type =~ m{^multipart/alternative};
|
||||||
|
# try to detect auto generated messages and drop them
|
||||||
my $skipAuto = 0;
|
my $skipAuto = 0;
|
||||||
my @headlines = split("\n",$head->stringify);
|
my @headlines = split("\n",$head->stringify);
|
||||||
foreach my $headline (@headlines) {
|
foreach my $headline (@headlines) {
|
||||||
|
|
@ -197,6 +208,11 @@ sub getNextMessage {
|
||||||
my @segments = ();
|
my @segments = ();
|
||||||
my @parts = $parsedMessage->parts;
|
my @parts = $parsedMessage->parts;
|
||||||
push(@parts, $parsedMessage) unless (@parts); # deal with the fact that there might be only one part
|
push(@parts, $parsedMessage) unless (@parts); # deal with the fact that there might be only one part
|
||||||
|
# If this message has alternates, the last is the most canonical
|
||||||
|
if ($alternate) {
|
||||||
|
@parts = reverse @parts;
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $part (@parts) {
|
foreach my $part (@parts) {
|
||||||
my $type = $part->mime_type;
|
my $type = $part->mime_type;
|
||||||
next if ($type eq "message/rfc822");
|
next if ($type eq "message/rfc822");
|
||||||
|
|
@ -210,18 +226,33 @@ sub getNextMessage {
|
||||||
$content = $body->as_string;
|
$content = $body->as_string;
|
||||||
}
|
}
|
||||||
next unless ($content);
|
next unless ($content);
|
||||||
push(@segments, {
|
|
||||||
filename=>$filename,
|
# If this is a multipart alternative message, and this is the first segment
|
||||||
type=>$type,
|
# Or if this is a normal mime message
|
||||||
content=>$content
|
if (($alternate && !@segments) || !$alternate) {
|
||||||
});
|
# Add the segment
|
||||||
|
push(@segments, {
|
||||||
|
filename=>$filename,
|
||||||
|
type=>$type,
|
||||||
|
content=>$content
|
||||||
|
});
|
||||||
|
}
|
||||||
|
# If this is a multipart alternative message, and this is not the first segment
|
||||||
|
elsif ($alternate) {
|
||||||
|
# Add an alternative to the last segment
|
||||||
|
push @{$segments[-1]->{alternative}}, {
|
||||||
|
type => $type,
|
||||||
|
content => $content,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unless (scalar(@segments) > 0) { # drop empty messages
|
unless (scalar(@segments) > 0) { # drop empty messages
|
||||||
$self->session->errorHandler->info("POP3: Dropped empty message ".$data{messageId}." from ".$data{from}." to ".$data{to});
|
$self->session->errorHandler->info("POP3: Dropped empty message ".$data{messageId}." from ".$data{from}." to ".$data{to});
|
||||||
return $self->getNextMessage;
|
return $self->getNextMessage;
|
||||||
}
|
}
|
||||||
$data{parts} = \@segments;
|
$data{parts} = \@segments;
|
||||||
return \%data;
|
use Data::Dumper; $self->session->errorHandler->warn(Dumper \%data);
|
||||||
|
return \%data;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue