/**
* Parse the information in mailing list headers.
*
* @param string $id The header ID.
* @param string $data The header text to process.
*
* @return string The HTML-escaped header value.
*/
protected function _parseListHeaders($id, $data)
{
global $injector;
$parser = $injector->getInstance('Horde_ListHeaders');
$text_filter = $injector->getInstance('Horde_Core_Factory_TextFilter');
$parsed = $parser->parse($id, $data);
if ($parsed instanceof Horde_ListHeaders_Id) {
$out = $parsed->id;
if ($parsed->label) {
$out .= ' -- <em>' . $parsed->label . '</em>';
}
return $out;
}
foreach ($parsed as $val) {
/* RFC 2369 [2] states that we should only show the *FIRST* URL
* that appears in a header that we can adequately handle. */
if (stripos($val->url, 'mailto:') === 0) {
$url = substr($val->url, 7);
$clink = new IMP_Compose_Link($url);
$out = Horde::link($clink->link()) . $url . '</a>';
foreach ($val->comments as $val2) {
$out .= htmlspecialchars('(' . $val2 . ')');
}
return $out;
} elseif ($url = $text_filter->filter($val->url, 'Linkurls')) {
$out = $url;
foreach ($val->comments as $val2) {
$out .= htmlspecialchars('(' . $val2 . ')');
}
return $out;
}
}
/* Pass through Linkurls filter anyway, since it is possible the
* sender did not correctly put URL between brackets. */
return Horde_Text_Filter_Linkurls::decode(htmlspecialchars($text_filter->filter($data, 'Linkurls', array('encode' => true))));
}