Subject: | Sent-date missing or incorrect |
With several .msg files, the date when the mail was sent is buried in
the property stream of the root object/directory.
Suggested fixes:
1. There was a problem when the oledate was undef.
Attachment: Message-datearr.diff
2. Parsing the root property stream:
Attachment: Message-propdate.diff
3. Annoyance avoider (more properties to ignore)
Attachment: Message-propdate.diff
After applying the patches I had the test suite run:
root@Breakfast:/usr/share/perl5/Email/Outlook/Email-Outlook-Message-0.907#
ls
blib Build.PL build-stamp Changes debian install-stamp lib
Makefile Makefile.PL MANIFEST META.yml pm_to_blib README t TODO
root@Breakfast:/usr/share/perl5/Email/Outlook/Email-Outlook-Message-0.907#
make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/basics.................ok
t/gpg_signed.............ok
t/internals..............ok
t/plain_jpeg_attached....ok
t/plain_uc_unsent........ok
t/plain_unsent...........ok
t/pod_coverage...........ok
All tests successful.
Files=7, Tests=59, 1 wallclock secs ( 0.99 cusr + 0.06 csys = 1.05 CPU)
root@Breakfast:/usr/share/perl5/Email/Outlook/Email-Outlook-Message-0.907#
Sorry Matijs for bothering you with PM yesterday - I should have checked
for the bug tacker, first.
Jordan
Subject: | Message-datearr.diff |
--- /usr/share/perl5/Email/Outlook/Message.bak 2009-09-07 17:32:59.000000000 +0100
+++ /usr/share/perl5/Email/Outlook/Message.pm 2009-09-07 17:34:20.000000000 +0100
@@ -560,8 +560,8 @@
# Make Date
my $datearr;
$datearr = $pps->{Time2nd};
- $datearr = $pps->{Time1st} unless($datearr);
- $self->{OLEDATE} = $self->_format_date($datearr) if $datearr;
+ $datearr = $pps->{Time1st} unless($datearr && @$datearr);
+ $self->{OLEDATE} = $self->_format_date($datearr) if $datearr && @$datearr;
}
return;
}
Subject: | Message-skipproperties.diff |
--- /usr/share/perl5/Email/Outlook/Message.bak 2009-09-07 17:32:59.000000000 +0100
+++ /usr/share/perl5/Email/Outlook/Message.pm 2009-09-07 17:38:57.000000000 +0100
@@ -109,7 +109,9 @@
# Content properties
'1008' => "Summary or something",
'1009' => "RTF Compressed",
+ '10F3' => "Subject",
# --
+ '1039' => "References, trouble ticket etc.",
'1046' => "From address variant",
# 'Common property'
'3001' => "Display name",
@@ -124,6 +126,7 @@
'370A' => "Tag identifying application that supplied the attachment",
'3713' => "Icon URL?",
# 'Mail user'
+ '3A00' => "aPage - internal?",
'3A20' => "Address variant",
# 3900 -- 39FF: 'Address book'
'39FF' => "7 bit display name",
Subject: | Message-propdate.diff |
--- /usr/share/perl5/Email/Outlook/Message.bak 2009-09-07 17:32:59.000000000 +0100
+++ /usr/share/perl5/Email/Outlook/Message.pm 2009-09-07 17:36:45.000000000 +0100
@@ -201,6 +201,13 @@
'39FE' => "SMTPADDRESS", # SMTP Address variant
};
+my $MAP_PROPSTREAM_TAG = {
+ 0x3007 => 'DATE2ND', # Outlook created??
+ 0x0039 => 'DATE1ST', # Outlook sent date
+ # 0x0E06 => 'DATE2ND', # more dates, not needed here
+ # 0x3008 => 'DATE2ND',
+};
+
#
# Main body of module
#
@@ -318,7 +325,7 @@
if ($child->{Type} == $DIR_TYPE) {
$self->_process_subdirectory($child);
} elsif ($child->{Type} == $FILE_TYPE) {
- $self->_process_pps_file_entry($child, $self, $MAP_SUBITEM_FILE);
+ $self->_process_pps_file_entry($child, $self, $MAP_SUBITEM_FILE, $MAP_PROPSTREAM_TAG);
} else {
carp "Unknown entry type: $child->{Type}";
}
@@ -451,13 +458,36 @@
return;
}
+sub _process_prop_stream {
+ my ($self, $target, $data, $map) = @_;
+ my ($n, $len) = (32, length $data) ;
+
+ while ($n + 16 <= $len) {
+ my @f = unpack "v4", substr $data, $n, 8;
+ my $t = $map->{$f [1]} ;
+ # $f[2]: bit 1 -- mandatory, bit 2 -- readable, bit 3 -- writable
+ next unless $t && ($f [2] & 2) && $f [3] == 0;
+
+ # At the moment, there are only date entries ...
+ my @a = OLE::Storage_Lite::OLEDate2Local substr $data, $n + 8, 8;
+
+ if ($t eq 'DATE1ST') {
+ unshift @{$target->{PROPDATE}}, $self->_format_date (\@a) ;
+ } else { # DATE2ND
+ push @{$target->{PROPDATE}}, $self->_format_date (\@a) ;
+ }
+ } continue {
+ $n += 16 ;
+ }
+}
+
#
# Generic processor for a file entry: Inserts the entry's data into the
# hash $target, using the $map to find the proper key.
# TODO: Mapping should probably be applied at a later time instead.
#
sub _process_pps_file_entry {
- my ($self, $pps, $target, $map) = @_;
+ my ($self, $pps, $target, $map, $map2) = @_;
my $name = $self->_get_pps_name($pps);
my ($property, $encoding) = $self->_parse_item_name($name);
@@ -475,6 +505,9 @@
$data =~ s/\r\n/\n/sg;
}
$target->{$key} = $data;
+ }
+ elsif ($name eq '__properties_version1 0' && $map2) {
+ $self->_process_prop_stream ($target, $pps->{Data}, $map2);
} else {
$self->_warn_about_unknown_file($pps);
}
@@ -755,6 +788,9 @@
# Second preferred option: get it from the SUBMISSION_ID:
$self->_AddHeaderField($mime, 'Date', $self->_submission_id_date());
+ # Most prefered option from the property list
+ $self->_AddHeaderField($mime, 'Date', $self->{PROPDATE}->[0]);
+
# After this, we'll try getting the date from the original headers.
return;
}