/usr/share/php/Horde/Mime/Viewer/Plain.php is in php-horde-mime-viewer 2.1.2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | <?php
/**
* The Horde_Mime_Viewer_Plain class renders out plain text with URLs made
* into hyperlinks (if viewing inline).
*
* Copyright 1999-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Anil Madhavapeddy <anil@recoil.org>
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Mime_Viewer
*/
class Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Base
{
/**
* This driver's display capabilities.
*
* @var array
*/
protected $_capability = array(
'full' => true,
'info' => false,
'inline' => true,
'raw' => false
);
/**
* Return the full rendered version of the Horde_Mime_Part object.
*
* @return array See parent::render().
*/
protected function _render()
{
$text = $this->_mimepart->getContents();
$charset = $this->_mimepart->getCharset();
/* Check for 'flowed' text data. */
if ($this->_mimepart->getContentTypeParameter('format') == 'flowed') {
$text = $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp'));
}
$text = '<html><body><tt>' . $this->_textFilter($text, 'Text2html', array(
'charset' => $charset,
'parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL
)) . '</tt></body></html>';
return $this->_renderReturn(
$text,
'text/html; charset=' . $charset
);
}
/**
* Return the rendered inline version of the Horde_Mime_Part object.
*
* @return array See parent::render().
*/
protected function _renderInline()
{
$text = Horde_String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset(), 'UTF-8');
/* Check for 'flowed' text data. */
$data = ($this->_mimepart->getContentTypeParameter('format') == 'flowed')
? $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp'))
: $text;
return $this->_renderReturn(
$data,
'text/html; charset=UTF-8'
);
}
/**
* Format flowed text for HTML output.
*
* @param string $text The text to format.
* @param boolean $delsp Was text created with DelSp formatting?
*
* @return string The formatted text.
*/
protected function _formatFlowed($text, $delsp = null)
{
$flowed = new Horde_Text_Flowed($text, $this->_mimepart->getCharset());
$flowed->setMaxLength(0);
if (!is_null($delsp)) {
$flowed->setDelSp($delsp);
}
return $flowed->toFixed();
}
}
|