while (list($uid, $ob) = each($fetch_ret)) {
$date = $imp_ui->getDate($ob['envelope']['date']);
- $from = $imp_ui->getFrom($ob, false);
- $subject = $imp_ui->getSubject($ob['envelope']['subject']);
+ $from = $imp_ui->getFrom($ob, array('specialchars' => $charset));
+ $subject = $imp_ui->getSubject($ob['envelope']['subject'], true);
$html .= '<tr style="cursor:pointer" class="text" onclick="DimpBase.go(\'msg:INBOX:' . $uid . '\');return false;"><td>' .
- '<strong>' . htmlspecialchars($from['from'], ENT_QUOTES, $charset) . '</strong><br />' .
+ '<strong>' . $from['from'] . '</strong><br />' .
$subject . '</td>' .
'<td>' . htmlspecialchars($date, ENT_QUOTES, $charset) . '</td></tr>';
}
/**
* Get From address information for display on mailbox page.
*
- * @param array $ob An array of envelope information.
- * @param boolean $full If true, returns 'fullfrom' information.
+ * @param array $ob An array of envelope information.
+ * @param array $options Additional options:
+ * <pre>
+ * 'fullfrom' - (boolean) If true, returns 'fullfrom' information.
+ * DEFAULT: false
+ * 'specialchars' - (string) If set, run 'from' return through
+ * htmlspecialchars() using the given charset.
+ * </pre>
*
* @return array An array of information:
* <pre>
* 'to' - (boolean)
* </pre>
*/
- public function getFrom($ob, $full = true)
+ public function getFrom($ob, $options = array())
{
$ret = array('error' => false, 'to' => false);
$ret['from'] = empty($first_to['personal'])
? $first_to['inner']
: $first_to['personal'];
- if ($full) {
+ if (!empty($options['fullfrom'])) {
$ret['fullfrom'] = $first_to['display'];
}
}
if ($this->_cache['drafts_sm_folder']) {
$ret['from'] = _("From") . ': ' . $ret['from'];
}
- if ($full) {
+ if (!empty($options['fullfrom'])) {
$ret['fullfrom'] = $from['display'];
}
}
$ret['fullfrom'] = $ret['from'];
}
+ if (!empty($ret['from']) && !empty($options['specialchars'])) {
+ $old_error = error_reporting(0);
+ $res = htmlspecialchars($ret['from'], ENT_QUOTES, $options['specialchars']);
+ if (empty($res)) {
+ $res = htmlspecialchars($ret['from']);
+ }
+ $ret['from'] = $res;
+ error_reporting($old_error);
+ }
+
return $ret;
}
}
$new_subject = $subject = IMP::filterText(preg_replace("/\s+/", ' ', $subject));
- if ($_SESSION['imp']['view'] == 'dimp') {
- require_once 'Horde/Text.php';
- $new_subject = str_replace(' ', ' ', Text::htmlSpaces($subject));
- } elseif ($htmlspaces) {
+
+ if ($htmlspaces) {
require_once 'Horde/Text.php';
$new_subject = Text::htmlSpaces($subject);
+ if (empty($new_subject)) {
+ $new_subject = htmlspecialchars($subject);
+ }
}
return empty($new_subject) ? $subject : $new_subject;
$msg['date'] = htmlspecialchars($imp_ui->getDate($ob['envelope']['date']), ENT_QUOTES, $charset);
/* Format the From: Header. */
- $getfrom = $imp_ui->getFrom($ob['envelope'], false);
- $msg['from'] = htmlspecialchars($getfrom['from'], ENT_QUOTES, $charset);
+ $getfrom = $imp_ui->getFrom($ob['envelope'], array('specialchars' => $charset));
+ $msg['from'] = $getfrom['from'];
/* Format the Subject: Header. */
- $msg['subject'] = $imp_ui->getSubject($ob['envelope']['subject']);
+ $msg['subject'] = $imp_ui->getSubject($ob['envelope']['subject'], true);
/* Check to see if this is a list message. Namely, we want to
* check for 'List-Post' information because that is the header
);
/* Format the from header. */
- $getfrom = $imp_ui->getFrom($ob['envelope'], false);
+ $getfrom = $imp_ui->getFrom($ob['envelope']);
$msg['from'] = $getfrom['from'];
if (String::length($msg['from']) > $conf['mimp']['mailbox']['max_from_chars']) {
$msg['from'] = String::substr($msg['from'], 0, $conf['mimp']['mailbox']['max_from_chars']) . '...';
}
/* Format the From: Header. */
- $getfrom = $imp_ui->getFrom($ob['envelope']);
- $msg['from'] = htmlspecialchars($getfrom['from']);
+ $getfrom = $imp_ui->getFrom($ob['envelope'], array('fullfrom' => true, 'specialchars' => NLS::getCharset()));
+ $msg['from'] = $getfrom['from'];
$msg['fullfrom'] = $getfrom['fullfrom'];
switch ($fromlinkstyle) {
case 0:
$overview = $imp_mailbox->getMailboxArray(array_slice($ids, 0, 20), $conf['mailbox']['show_preview'] && $prefs->getValue('preview_enabled'));
foreach ($overview['overview'] as $ob) {
- $from_addr = $imp_ui->getFrom($ob['envelope']);
+ $from_addr = $imp_ui->getFrom($ob['envelope'], array('fullfrom' => true));
$items[] = array_map('htmlspecialchars', array(
'title' => $imp_ui->getSubject($ob['envelope']['subject']),
'pubDate' => date('r', strtotime($ob['envelope']['date'])),