Skip to content

Commit 8ff2782

Browse files
committed
Catching and handling iconv decoding exception Webklex#397
1 parent f1d82d9 commit 8ff2782

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
1111
- Protocol exception handling improved (bad response message added) #408
1212
- Prevent fetching singular rfc partials from running indefinitely #407
1313
- Subject with colon ";" is truncated #401
14+
- Catching and handling iconv decoding exception #397
1415

1516
### Added
1617
- NaN

src/Message.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,11 @@ public function convertEncoding($str, string $from = "ISO-8859-2", string $to =
903903
}
904904

905905
if (function_exists('iconv') && !EncodingAliases::isUtf7($from) && !EncodingAliases::isUtf7($to)) {
906-
return @iconv($from, $to . '//IGNORE', $str);
906+
try {
907+
return iconv($from, $to.'//IGNORE', $str);
908+
} catch (\Exception $e) {
909+
return @iconv($from, $to, $str);
910+
}
907911
} else {
908912
if (!$from) {
909913
return mb_convert_encoding($str, $to);

0 commit comments

Comments
 (0)