Esempio n. 1
0
 public function testBug9992()
 {
     $text = base64_decode('dGVzdDogtbno6bvtu+nt/eHpu7797Txicj4K');
     $expected = '<p>test: ľščéťíťéíýáéťžýí<br/></p>';
     $dom = new Horde_Domhtml($text, 'iso-8859-2');
     $this->assertEquals(Horde_String::convertCharset($expected, 'UTF-8', 'iso-8859-2'), strtr(trim($dom->returnBody()), array("\n" => '')));
     $this->assertEquals('UTF-8', $dom->getCharset());
 }
Esempio n. 2
0
 /**
  * Executes any code necessary after applying the filter patterns.
  *
  * @param string $text  The text after the filtering.
  *
  * @return string|Horde_Domhtml  The modified text or a Domhtml object if
  *                               the 'return_dom' parameter is set.
  * @throws Exception
  */
 public function postProcess($text)
 {
     $dom = new Horde_Domhtml($text, $this->_params['charset']);
     foreach ($dom as $node) {
         $this->_node($node);
     }
     if ($this->_params['noprefetch']) {
         $meta = $dom->dom->createElement('meta');
         $meta->setAttribute('http-equiv', 'x-dns-prefetch-control');
         $meta->setAttribute('value-equiv', 'off');
         $head = $dom->getHead();
         $head->appendChild($meta);
     }
     if ($this->_params['return_dom']) {
         return $dom;
     }
     return $this->_params['return_document'] ? $dom->returnHtml() : $dom->returnBody();
 }
Esempio n. 3
0
File: Mail.php Progetto: horde/horde
 /**
  * Return the body text of the original email from a smart request.
  *
  * @param array $body_data       The body data array of the source msg.
  * @param Horde_Mime_Part $part  The body mime part of the email to send.
  * @param boolean $html          Do we want an html body?
  * @param boolean $flow          Should the body be flowed?
  *
  * @return string  The properly formatted/flowed message body.
  */
 protected function _msgBody(array $body_data, Horde_Mime_Part $part, $html, $flow = false)
 {
     $subtype = $html == true ? 'html' : 'plain';
     $msg = Horde_String::convertCharset((string) $body_data[$subtype]['body'], $body_data[$subtype]['charset'], 'UTF-8');
     if (!$html) {
         if ($part->getContentTypeParameter('format') == 'flowed') {
             $flowed = new Horde_Text_Flowed($msg, 'UTF-8');
             if (Horde_String::lower($part->getContentTypeParameter('delsp')) == 'yes') {
                 $flowed->setDelSp(true);
             }
             $flowed->setMaxLength(0);
             $msg = $flowed->toFixed(false);
         } else {
             // If not flowed, remove padding at eol
             $msg = preg_replace("/\\s*\n/U", "\n", $msg);
         }
         if ($flow) {
             $flowed = new Horde_Text_Flowed($msg, 'UTF-8');
             $msg = $flowed->toFlowed(true);
         }
     } else {
         // This filter requires the tidy extenstion.
         if (Horde_Util::extensionExists('tidy')) {
             return Horde_Text_Filter::filter($msg, 'Cleanhtml', array('body_only' => true));
         } else {
             // If no tidy, use Horde_Dom.
             $dom = new Horde_Domhtml($msg, 'UTF-8');
             return $dom->returnBody();
         }
     }
     return $msg;
 }