This file is indexed.

/usr/share/php/Horde/Mail/Rfc822/Address.php is in php-horde-mail 2.1.4-1.

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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<?php
/**
 * Copyright 2012-2013 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (BSD). If you
 * did not receive this file, see http://www.horde.org/licenses/bsd.
 *
 * @category  Horde
 * @copyright 2012-2013 Horde LLC
 * @license   http://www.horde.org/licenses/bsd New BSD License
 * @package   Mail
 */

/**
 * Object representation of a RFC 822 e-mail address.
 *
 * @author    Michael Slusarz <slusarz@horde.org>
 * @category  Horde
 * @copyright 2012-2013 Horde LLC
 * @license   http://www.horde.org/licenses/bsd New BSD License
 * @package   Mail
 *
 * @property-read string $bare_address  The bare mailbox@host address.
 * @property-read string $bare_address_idn  The bare mailbox@host address (IDN
 *                                          encoded). (@since 2.1.0)
 * @property-read string $encoded  The full MIME/IDN encoded address (UTF-8).
 * @property string $host  Returns the host part (UTF-8).
 * @property-read string $host_idn  Returns the IDN encoded host part.
 * @property-read string $label  The shorthand label for this address.
 * @property string $personal  The personal part (UTF-8).
 * @property-read string $personal_encoded  The MIME encoded personal part
 *                                          (UTF-8).
 * @property-read boolean $valid  Returns true if there is enough information
 *                                in object to create a valid address.
 */
class Horde_Mail_Rfc822_Address extends Horde_Mail_Rfc822_Object
{
    /**
     * Comments associated with the personal phrase.
     *
     * @var array
     */
    public $comment = array();

    /**
     * Local-part of the address.
     *
     * @var string
     */
    public $mailbox = null;

    /**
     * Hostname of the address.
     *
     * @var string
     */
    protected $_host = null;

    /**
     * Personal part of the address.
     *
     * @var string
     */
    protected $_personal = null;

    /**
     * Constructor.
     *
     * @param string $address  If set, address is parsed and used as the
     *                         object address. Address is not validated;
     *                         first e-mail address parsed is used.
     */
    public function __construct($address = null)
    {
        if (!is_null($address)) {
            $rfc822 = new Horde_Mail_Rfc822();
            $addr = $rfc822->parseAddressList($address);
            if (count($addr)) {
                foreach ($addr[0] as $key => $val) {
                    $this->$key = $val;
                }
            }
        }
    }

    /**
     */
    public function __set($name, $value)
    {
        switch ($name) {
        case 'host':
            $value = ltrim($value, '@');
            $this->_host = function_exists('idn_to_utf8')
                ? strtolower(idn_to_utf8($value))
                : strtolower($value);
            break;

        case 'personal':
            $this->_personal = strlen($value)
                ? Horde_Mime::decode($value)
                : null;
            break;
        }
    }

    /**
     */
    public function __get($name)
    {
        switch ($name) {
        case 'bare_address':
            return is_null($this->host)
                ? $this->mailbox
                : $this->mailbox . '@' . $this->host;

        case 'bare_address_idn':
            $personal = $this->_personal;
            $this->_personal = null;
            $res = $this->encoded;
            $this->_personal = $personal;
            return $res;

        case 'encoded':
            return $this->writeAddress(true);

        case 'host':
            return $this->_host;

        case 'host_idn':
            return function_exists('idn_to_ascii')
                ? idn_to_ascii($this->_host)
                : $this->host;

        case 'label':
            return is_null($this->personal)
                ? $this->bare_address
                : $this->_personal;

        case 'personal':
            return (strcasecmp($this->_personal, $this->bare_address) === 0)
                ? null
                : $this->_personal;

        case 'personal_encoded':
            return Horde_Mime::encode($this->personal);

        case 'valid':
            return (bool)strlen($this->mailbox);

        default:
            return null;
        }
    }

    /**
     */
    protected function _writeAddress($opts)
    {
        $rfc822 = new Horde_Mail_Rfc822();

        $address = $rfc822->encode($this->mailbox, 'address');
        $host = empty($opts['idn']) ? $this->host : $this->host_idn;
        if (strlen($host)) {
            $address .= '@' . $host;
        }
        $personal = $this->personal;
        if (strlen($personal)) {
            if (!empty($opts['encode'])) {
                $personal = Horde_Mime::encode($this->personal, $opts['encode']);
            }
            $personal = $rfc822->encode($personal, 'personal');
        }

        return (strlen($personal) && ($personal != $address))
            ? $personal . ' <' . $address . '>'
            : $address;
    }

    /**
     */
    public function match($ob)
    {
        if (!($ob instanceof Horde_Mail_Rfc822_Address)) {
            $ob = new Horde_Mail_Rfc822_Address($ob);
        }

        return ($this->bare_address == $ob->bare_address);
    }

    /**
     * Do a case-insensitive match on the address. Per RFC 822/2822/5322,
     * although the host portion of an address is case-insensitive, the
     * mailbox portion is platform dependent.
     *
     * @param mixed $ob  Address data.
     *
     * @return boolean  True if the data reflects the same case-insensitive
     *                  address.
     */
    public function matchInsensitive($ob)
    {
        if (!($ob instanceof Horde_Mail_Rfc822_Address)) {
            $ob = new Horde_Mail_Rfc822_Address($ob);
        }

        return (Horde_String::lower($this->bare_address) == Horde_String::lower($ob->bare_address));
    }

    /**
     * Do a case-insensitive match on the address for a given domain.
     * Matches as many parts of the subdomain in the address as is given in
     * the input.
     *
     * @param string $domain  Domain to match.
     *
     * @return boolean  True if the address matches the given domain.
     */
    public function matchDomain($domain)
    {
        $host = $this->host;
        if (is_null($host)) {
            return false;
        }

        $match_domain = explode('.', $domain);
        $match_host = array_slice(explode('.', $host), count($match_domain) * -1);

        return (strcasecmp($domain, implode('.', $match_host)) === 0);
    }

}