Skip to content

Commit

Permalink
Catching and handling iconv decoding exception #397
Browse files Browse the repository at this point in the history
  • Loading branch information
Webklex committed Jun 23, 2023
1 parent f1d82d9 commit 8ff2782
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
- Protocol exception handling improved (bad response message added) #408
- Prevent fetching singular rfc partials from running indefinitely #407
- Subject with colon ";" is truncated #401
- Catching and handling iconv decoding exception #397

### Added
- NaN
Expand Down
6 changes: 5 additions & 1 deletion src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,11 @@ public function convertEncoding($str, string $from = "ISO-8859-2", string $to =
}

if (function_exists('iconv') && !EncodingAliases::isUtf7($from) && !EncodingAliases::isUtf7($to)) {
return @iconv($from, $to . '//IGNORE', $str);
try {
return iconv($from, $to.'//IGNORE', $str);
} catch (\Exception $e) {
return @iconv($from, $to, $str);
}
} else {
if (!$from) {
return mb_convert_encoding($str, $to);
Expand Down

0 comments on commit 8ff2782

Please sign in to comment.