diff options
author | Cyrille Bollu <cyr.debian@bollu.be> | 2021-02-02 17:29:50 +0300 |
---|---|---|
committer | Cyrille Bollu <cyr.debian@bollu.be> | 2021-02-02 17:50:51 +0300 |
commit | ea362877b1a25d0272b7a211858e7531cb7d9829 (patch) | |
tree | 0c527e58aceff4f2e8188f4656d1bc77f6be5fd0 /lib/Model | |
parent | ba40c6e1c51e80ff87aa68cd434cb1e6cd40e147 (diff) |
Avoids using iconv with '//IGNORE' flag if possible
Signed-off-by: Cyrille Bollu <cyr.debian@bollu.be>
Diffstat (limited to 'lib/Model')
-rw-r--r-- | lib/Model/IMAPMessage.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Model/IMAPMessage.php b/lib/Model/IMAPMessage.php index ec97180d6..1841d1cb2 100644 --- a/lib/Model/IMAPMessage.php +++ b/lib/Model/IMAPMessage.php @@ -273,7 +273,14 @@ class IMAPMessage implements IMessage, JsonSerializable { * @return string */ public function getSubject(): string { - return iconv("UTF-8", "UTF-8//IGNORE", $this->getEnvelope()->subject); + // Try a soft conversion first (some installations, eg: Alpine linux, + // have issues with the '//IGNORE' option) + $subject = $this->getEnvelope()->subject; + $utf8 = iconv('UTF-8', 'UTF-8', $subject); + if ($utf8 !== false) { + return $utf8; + } + return iconv("UTF-8", "UTF-8//IGNORE", $subject); } /** |