Skip to content

Commit 8354f23

Browse files
committed
Prevent text bodies from being fetched as attachment Webklex#27
1 parent 6b82256 commit 8354f23

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
66

77
## [UNRELEASED]
88
### Fixed
9-
- NaN
9+
- Prevent text bodies from being fetched as attachment #27
1010

1111
### Added
1212
- NaN
1313

1414
### Affected Classes
15-
- NaN
15+
- [Message::class](src/Message.php)
16+
17+
### Breaking changes
18+
- Text bodies might no longer get fetched as attachment
1619

1720
## [2.1.13] - 2020-10-13
1821
### Fixed

src/Message.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ private function fetchPart(Part $part) {
436436

437437
if ($part->type == IMAP::MESSAGE_TYPE_TEXT && ($part->ifdisposition == 0 || (empty($part->disposition) || !in_array(strtolower($part->disposition), ['attachment', 'inline'])) ) ) {
438438

439-
if (strtolower($part->subtype) == "plain" || strtolower($part->subtype) == "csv") {
439+
if ( in_array(($subtype = strtolower($part->subtype)), ["plain", "csv", "html"]) && $part->filename == null && $part->name == null) {
440440
$encoding = $this->getEncoding($part);
441441

442442
$content = $this->decodeString($part->content, $part->encoding);
@@ -456,20 +456,8 @@ private function fetchPart(Part $part) {
456456
$content = $this->convertEncoding($content, $encoding);
457457
}
458458

459-
$this->bodies['text'] = $content;
460-
461-
$this->fetchAttachment($part);
462-
463-
} elseif (strtolower($part->subtype) == "html") {
464-
$encoding = $this->getEncoding($part);
465-
466-
$content = $this->decodeString($part->content, $part->encoding);
467-
if ($encoding != 'us-ascii') {
468-
$content = $this->convertEncoding($content, $encoding);
469-
}
470-
471-
$this->bodies['html'] = $content;
472-
} elseif ($part->ifdisposition == 1 && strtolower($part->disposition) == 'attachment') {
459+
$this->bodies[$subtype == "plain" ? "text" : $subtype] = $content;
460+
} else {
473461
$this->fetchAttachment($part);
474462
}
475463
} else {

0 commit comments

Comments
 (0)