From: Michael M Slusarz Date: Tue, 11 Nov 2008 20:03:33 +0000 (-0700) Subject: Check for UTF-8 browsers when viewing text inline X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=82fb35a2b7c025c4a701be2ecafade7f606536dc;p=horde.git Check for UTF-8 browsers when viewing text inline --- diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index 7cbdde89c..ca06d8cba 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -313,6 +313,26 @@ class IMP_Contents $ret = $viewer->render($mode); $ret['name'] = $mime_part->getName(true); + + /* If this is a text/* part, AND the browser does not support UTF-8, + * give the user a link to open the part in a new window with the + * correct character set. */ + if (($mode != 'full') && ($mime_part->getPrimaryType() == 'text')) { + $default_charset = String::upper(NLS::getCharset()); + if ($default_charset !== 'UTF-8') { + $charset_upper = String::upper($mime_part->getCharset()); + if (($charset_upper != 'US-ASCII') && + ($charset_upper != $default_charset)) { + $ret['status'][] = array( + 'text' => array( + sprintf(_("This message was written in a character set (%s) other than your own."), htmlspecialchars($charset_upper)), + sprintf(_("If it is not displayed correctly, %s to open it in a new window."), $this->linkViewJS($mime_part, 'view_attach', _("click here"))) + ) + ); + } + } + } + return $ret; }