Skip to content

Commit

Permalink
Handle reading charset=binary correctly #95
Browse files Browse the repository at this point in the history
  • Loading branch information
zbateson committed Nov 18, 2019
1 parent 861834d commit adaf3e3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Message/Part/MimePart.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function isMime()
*/
public function isTextPart()
{
return ($this->getCharset() !== null && strcasecmp($this->getCharset(), 'binary') !== 0);
return ($this->getCharset() !== null);
}

/**
Expand All @@ -91,13 +91,17 @@ public function getContentType($default = 'text/plain')
* Returns the upper-cased charset of the Content-Type header's charset
* parameter if set, ISO-8859-1 if the Content-Type is text/plain or
* text/html and the charset parameter isn't set, or null otherwise.
*
* If the charset parameter is set to 'binary' it is ignored and considered
* 'not set' (returns ISO-8859-1 for text/plain, text/html or null
* otherwise).
*
* @return string
*/
public function getCharset()
{
$charset = $this->getHeaderParameter('Content-Type', 'charset');
if ($charset === null) {
if ($charset === null || strcasecmp($charset, 'binary') === 0) {
$contentType = $this->getContentType();
if ($contentType === 'text/plain' || $contentType === 'text/html') {
return 'ISO-8859-1';
Expand Down

0 comments on commit adaf3e3

Please sign in to comment.