See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
1 <?php 2 /** 3 * Copyright 2014-2017 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file LICENSE for license information (LGPL). If you 6 * did not receive this file, see http://www.horde.org/licenses/lgpl21. 7 * 8 * @category Horde 9 * @copyright 2014-2017 Horde LLC 10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 11 * @package Mime 12 */ 13 14 /** 15 * Stream filter to determine whether body requires either binary or 8bit 16 * encoding (RFC 2045 [6]). 17 * 18 * @author Michael Slusarz <slusarz@horde.org> 19 * @category Horde 20 * @copyright 2014-2017 Horde LLC 21 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 22 * @package Mime 23 * @since 2.6.0 24 */ 25 class Horde_Mime_Filter_Encoding extends php_user_filter 26 { 27 /** 28 * Number of consecutive non-CR/LF characters. 29 * 30 * @var integer 31 */ 32 protected $_crlf = 0; 33 34 /** 35 * @see stream_filter_register() 36 */ 37 public function onCreate() 38 { 39 $this->params->body = false; 40 41 return true; 42 } 43 44 /** 45 * @see stream_filter_register() 46 */ 47 public function filter($in, $out, &$consumed, $closing) 48 { 49 while ($bucket = stream_bucket_make_writeable($in)) { 50 if ($this->params->body !== 'binary') { 51 $len = $bucket->datalen; 52 $str = $bucket->data; 53 54 for ($i = 0; $i < $len; ++$i) { 55 $chr = ord($str[$i]); 56 57 switch ($chr) { 58 case 0: 59 /* Only binary data can have NULLs. */ 60 $this->params->body = 'binary'; 61 break 2; 62 63 case 10: // LF 64 case 13: // CR 65 $this->_crlf = 0; 66 break; 67 68 default: 69 /* RFC 2045 [2.8]: 8bit data must be less than 998 70 * characters in length. Otherwise, we are looking at 71 * binary. */ 72 if (++$this->_crlf > 998) { 73 $this->params->body = 'binary'; 74 break 2; 75 } elseif ($chr > 127) { 76 $this->params->body = '8bit'; 77 } 78 break; 79 } 80 } 81 } 82 83 $consumed += $bucket->datalen; 84 stream_bucket_append($out, $bucket); 85 } 86 87 return PSFS_PASS_ON; 88 } 89 90 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body