See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
1 <?php 2 /** 3 * Copyright 2012-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 2012-2017 Horde LLC 10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 11 * @package Imap_Client 12 */ 13 14 /** 15 * Stream filter to analyze an IMAP string to determine how to send to the 16 * server. 17 * 18 * @author Michael Slusarz <slusarz@horde.org> 19 * @category Horde 20 * @copyright 2012-2017 Horde LLC 21 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 22 * @package Imap_Client 23 */ 24 class Horde_Imap_Client_Data_Format_Filter_String extends php_user_filter 25 { 26 /** 27 * Skip status. 28 * 29 * @var boolean 30 */ 31 protected $_skip = false; 32 33 /** 34 * @see stream_filter_register() 35 */ 36 #[ReturnTypeWillChange] 37 public function onCreate() 38 { 39 $this->params->binary = false; 40 $this->params->literal = false; 41 $this->params->nonascii = false; 42 // no_quote_list is used below as a config option 43 $this->params->quoted = false; 44 45 return true; 46 } 47 48 /** 49 * @see stream_filter_register() 50 */ 51 #[ReturnTypeWillChange] 52 public function filter($in, $out, &$consumed, $closing) 53 { 54 $p = $this->params; 55 56 while ($bucket = stream_bucket_make_writeable($in)) { 57 if (!$this->_skip) { 58 $len = $bucket->datalen; 59 $str = $bucket->data; 60 61 for ($i = 0; $i < $len; ++$i) { 62 $chr = ord($str[$i]); 63 64 switch ($chr) { 65 case 0: // null 66 $p->binary = true; 67 $p->literal = true; 68 69 // No need to scan input anymore. 70 $this->_skip = true; 71 break 2; 72 73 case 10: // LF 74 case 13: // CR 75 $p->literal = true; 76 break; 77 78 case 32: // SPACE 79 case 34: // " 80 case 40: // ( 81 case 41: // ) 82 case 92: // \ 83 case 123: // { 84 case 127: // DEL 85 // These are all invalid ATOM characters. 86 $p->quoted = true; 87 break; 88 89 case 37: // % 90 case 42: // * 91 // These are not quoted if being used as wildcards. 92 if (empty($p->no_quote_list)) { 93 $p->quoted = true; 94 } 95 break; 96 97 default: 98 if ($chr < 32) { 99 // CTL characters must be, at a minimum, quoted. 100 $p->quoted = true; 101 } elseif ($chr > 127) { 102 $p->nonascii = true; 103 // 8-bit chars must be in a literal. 104 $p->literal = true; 105 } 106 break; 107 } 108 } 109 } 110 111 $consumed += $bucket->datalen; 112 stream_bucket_append($out, $bucket); 113 } 114 115 if ($p->literal) { 116 $p->quoted = false; 117 } 118 119 return PSFS_PASS_ON; 120 } 121 122 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body