/usr/share/php/Horde/Mime/ContentParam/Decode.php is in php-horde-mime 2.10.3-1ubuntu1.
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | <?php
/**
* Copyright 2014-2017 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.
*
* Decoding parsing code adapted from rfc822-parser.c (Dovecot 2.2.13)
* Original code released under LGPL-2.1
* Copyright (c) 2002-2014 Timo Sirainen <tss@iki.fi>
*
* @category Horde
* @copyright 2002-2015 Timo Sirainen
* @copyright 2014-2017 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Mime
*/
/**
* Decode MIME content parameter data (RFC 2045; 2183; 2231).
*
* @author Timo Sirainen <tss@iki.fi>
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2002-2015 Timo Sirainen
* @copyright 2014-2017 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Mime
* @since 2.5.0
*/
class Horde_Mime_ContentParam_Decode extends Horde_Mail_Rfc822
{
/**
* Decode content parameter data.
*
* @param string $data Parameter data.
*
* @return array List of parameter key/value combinations.
*/
public function decode($data)
{
$out = array();
$this->_data = $data;
$this->_datalen = strlen($data);
$this->_ptr = 0;
while ($this->_curr() !== false) {
$this->_rfc822SkipLwsp();
$this->_rfc822ParseMimeToken($param);
if (is_null($param) || ($this->_curr() != '=')) {
break;
}
++$this->_ptr;
$this->_rfc822SkipLwsp();
$value = '';
if ($this->_curr() == '"') {
try {
$this->_rfc822ParseQuotedString($value);
} catch (Horde_Mail_Exception $e) {
break;
}
} else {
$this->_rfc822ParseMimeToken($value);
if (is_null($value)) {
break;
}
}
$out[$param] = $value;
$this->_rfc822SkipLwsp();
if ($this->_curr() != ';') {
break;
}
++$this->_ptr;
}
return $out;
}
/**
* Determine if character is a non-escaped element in MIME parameter data
* (See RFC 2045 [Appendix A]).
*
* @param string $c Character to test.
*
* @return boolean True if non-escaped character.
*/
public static function isAtextNonTspecial($c)
{
switch ($ord = ord($c)) {
case 34:
case 40:
case 41:
case 44:
case 47:
case 58:
case 59:
case 60:
case 61:
case 62:
case 63:
case 64:
case 91:
case 92:
case 93:
/* "(),/:;<=>?@[\] */
return false;
default:
/* CTLs, SPACE, DEL, non-ASCII */
return (($ord > 32) && ($ord < 127));
}
}
/**
*/
protected function _rfc822ParseMimeToken(&$str)
{
for ($i = $this->_ptr, $size = strlen($this->_data); $i < $size; ++$i) {
if (!self::isAtextNonTspecial($this->_data[$i])) {
break;
}
}
if ($i === $this->_ptr) {
$str = null;
} else {
$str = substr($this->_data, $this->_ptr, $i - $this->_ptr);
$this->_ptr += ($i - $this->_ptr);
$this->_rfc822SkipLwsp();
}
}
}
|