Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-Description fields are omitted with inline images (#16) #17

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -541,5 +541,6 @@ README.txt
RELNOTES
t/compile.t
t/readmail-MAILhead_get_disposition.t
t/readmail-MAILread_body.t
TODO
xt/perltidy.t
2 changes: 1 addition & 1 deletion lib/mhexternal.pl
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ sub filter {
$ret = '<p>'
. mhonarc::htmlize($fields->{'content-description'}[0])
. "</p>\n"
if (defined $fields{'content-description'});
if (defined $fields->{'content-description'});
$ret .= qq|<p><a href="$urlfile" $target><img src="$urlfile" |
. qq|alt="$type"></a></p>\n|;

Expand Down
58 changes: 58 additions & 0 deletions t/readmail-MAILread_body.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4

use strict;
use warnings;
use English qw(no_match_vars);
use Test::More;

require 'mhopt.pl';
require 'readmail.pl';
require 'ewhutil.pl'; # for htmlize()
# Dummies for tests
sub mhonarc::dir_create {1}
sub mhonarc::file_temp { my $x; open my $fh, '>', \$x; return ($fh, '') }
sub mhonarc::file_chmod {1}

mhonarc::mhinit_readmail_vars();

my @tests = map { [split /\n[.]\n/, $_] } split /\n[.][.]\n*/,
do { local $RS; <DATA> };

foreach my $test (@tests) {
my ($name, $mesg, $result) = @$test;
my ($fields, $header_txt) = readmail::MAILread_header(\$mesg);
my ($ret, @files) = readmail::MAILread_body($fields, \$mesg);

ok $ret =~ /$result/, $name;
diag "Returned:\n$ret" unless $ret =~ /$result/;
}

done_testing();

__END__
GH#16: Content-Description fields are omitted with inline images
.
Content-type: image/jpeg; name="image.jpg"
Content-Description: This is a JPEG file
Content-Disposition: inline; filename="image.jpg"
Content-transfer-encoding: base64

XXXX

.
This is a JPEG file
..
GH#16: Content-Description fields are omitted with inline images
.
Content-type: image/jpeg; name="image.jpg"
Content-Description: This is a JPEG file
Content-Disposition: attachment; filename="image.jpg"
Content-transfer-encoding: base64

XXXX

.
This is a JPEG file
..