From 82fb35a2b7c025c4a701be2ecafade7f606536dc Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 11 Nov 2008 13:03:33 -0700 Subject: [PATCH] Check for UTF-8 browsers when viewing text inline --- imp/lib/Contents.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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; } -- 2.11.0