Skip to content

Commit 00e053f

Browse files
authored
Merge pull request #1761 from kambereBr/enh-ews-msg-encoding
fix(backend): ews display attachment filenames for received messages
2 parents eff5d9a + c07de43 commit 00e053f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

modules/imap/hm-ews.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,9 +1043,21 @@ protected function parse_mime_part($part, &$struct, $part_num) {
10431043
$struct[$part_num]['md5'] = '';
10441044
$struct[$part_num]['disposition'] = $part->getContentDisposition();
10451045

1046-
if ($filename = $part->getFilename()) {
1046+
$filename = $part->getFilename();
1047+
if (! $filename) {
1048+
$filename = $part->getHeaderParameter('Content-Type', 'name');
1049+
}
1050+
if (! $filename) {
1051+
$filename = $part->getHeaderParameter('Content-Disposition', 'filename');
1052+
}
1053+
if ($filename) {
10471054
$struct[$part_num]['file_attributes'] = ['filename' => $filename];
10481055

1056+
if (! isset($struct[$part_num]['attributes']) || ! is_array($struct[$part_num]['attributes'])) {
1057+
$struct[$part_num]['attributes'] = [];
1058+
}
1059+
$struct[$part_num]['attributes']['name'] = $filename;
1060+
10491061
if ($part->getContentDisposition() == 'attachment') {
10501062
$struct[$part_num]['file_attributes']['attachment'] = true;
10511063
}

0 commit comments

Comments
 (0)