Skip to content

Commit

Permalink
Merge branch 'pu/ccheng/msg_emcode' into '2023.11'
Browse files Browse the repository at this point in the history
fix(Felamimail/Message): improve encoding detection

See merge request tine20/tine20!5220
  • Loading branch information
pschuele committed Apr 11, 2024
2 parents 9ca8586 + ee5b057 commit 9fccbb0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion tests/tine20/Felamimail/Controller/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public function testGetBodyMultipartRelated()

$this->assertStringContainsString('würde', $body);
}

/**
* test reading a message without setting the \Seen flag
*/
Expand Down Expand Up @@ -1478,6 +1478,7 @@ public function testMultipartRelatedAlternative()
$cachedMessage = $this->messageTestHelper('multipart_alternative_related.eml');
$message = $this->_getController()->getCompleteMessage($cachedMessage);
$this->assertStringContainsString('some body contentsome body contentsome body content', $message->body);
$this->assertStringContainsString('TEI™ Study', $message->body);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ some body contentsome body contentsome body content
some body contentsome body contentsome body content
some body contentsome body contentsome body content
some body contentsome body contentsome body content
Key insights from the Forrester TEI=E2=84=A2 Study
</body></html>
------=_NextPart_001_018A_01CE0BA2.ABFF5D10--
Expand All @@ -202,4 +203,3 @@ Mvg/NOjJWruUOkfOOjYRPVxDr3RgL/QLpDzMZWLNXrPWbDMMJagXWkATKKro4L1tKxsn5VGmlcsv
TRUNCATED
------=_NextPart_000_0189_01CE0BA2.ABFF5D10--
2 changes: 1 addition & 1 deletion tine20/Tinebase/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public static function in_array_case($_arr, $_str)
public static function mbConvertTo($string, $encodingTo = 'utf-8')
{
// try to fix bad encodings
$encoding = mb_detect_encoding((string)$string, array('utf-8', 'iso-8859-1', 'windows-1252', 'iso-8859-15'));
$encoding = mb_detect_encoding((string)$string, array('utf-8', 'iso-8859-1', 'iso-8859-15'));
if ($encoding !== FALSE) {
$string = @mb_convert_encoding((string)$string, $encodingTo, $encoding);
}
Expand Down
2 changes: 1 addition & 1 deletion tine20/library/StreamFilter/ConvertMbstring.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class StreamFilter_ConvertMbstring extends php_user_filter
*/
function filter($in, $out, &$consumed, $closing): int {
while ($bucket = stream_bucket_make_writeable($in)) {
$encoding = mb_detect_encoding($bucket->data, array('utf-8', 'iso-8859-1', 'windows-1252', 'iso-8859-15'));
$encoding = mb_detect_encoding($bucket->data, array('utf-8', 'iso-8859-1', 'iso-8859-15'));
if ($encoding !== FALSE) {
$bucket->data = @mb_convert_encoding($bucket->data, 'utf-8', $encoding);
}
Expand Down

0 comments on commit 9fccbb0

Please sign in to comment.