This file is indexed.

/usr/share/php/Horde/Compress/Tnef/Icalendar.php is in php-horde-compress 2.2.1-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
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
<?php
/**
 * Copyright 2002-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.
 *
 * @author   Michael J Rubinsky <mrubinsk@horde.org>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @package  Compress
 */

/**
 * Object to parse and represent iCalendar data encapsulated in a TNEF file.
 *
 * @author    Michael J Rubinsky <mrubinsk@horde.org>
 * @category  Horde
 * @copyright 2002-2017 Horde LLC
 * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @package   Compress
 */
class Horde_Compress_Tnef_Icalendar extends Horde_Compress_Tnef_Object
{
    const PART_ACTION    = 'NEEDS-ACTION';
    const PART_TENTATIVE = 'TENTATIVE';
    const PART_DECLINE   = 'DECLINE';
    const PART_ACCEPTED  = 'ACCEPTED';

    /**
     * ICalendar METHOD
     *
     * @var string
     */
    protected $_method;

    /**
     *
     * @var string
     */
    protected $_summary;

    /**
     *
     * @var string
     */
    protected $_location;

    /**
     *
     * @var string
     */
    protected $_url;

    /**
     *
     * @var Horde_Date
     */
    protected $_startUtc;

    /**
     *
     * @var Horde_Date
     */
    protected $_endUtc;

    /**
     *
     * @var string
     */
    protected $_duration;

    /**
     *
     * @var boolean
     */
    protected $_allday;

    /**
     *
     * @var string
     */
    protected $_organizer;

    /**
     *
     * @var string
     */
    protected $_lastModifier;

    /**
     * The "From" attribute used by iTip responses.
     *
     * @var string
     */
    protected $_from;

    /**
     *
     * @var string
     */
    protected $_uid;

    /**
     * Recurrence data.
     *
     * @var array
     */
    protected $_recurrence = array();

    /**
     *
     * @var integer
     */
    protected $_type;

    /**
     *
     * @var Horde_Date
     */
    protected $_created;

    /**
     *
     * @var Horde_Date
     */
    protected $_modified;

    /**
     * Cache of the iCalendar text.
     *
     * @var string
     */
    protected $_content;

    /**
     * List of required attendees parsed from the MAPI object.
     *
     * @var string
     */
    protected $_requiredAttendees;

    /**
     * The current PARTSTAT property for this meeting request.
     *
     * @var string  A self::PART_* constant.
     */
    protected $_partStat;

    /**
     * The description/body of the meeting request.
     *
     * @var string
     */
    protected $_description;

    /**
     * RSVP property
     *
     * @var boolean
     */
    protected $_rsvp = false;
    /**
     * MIME type.
     *
     * @var string
     */
    public $type = 'text/calendar';

    /**
     * Accessor
     *
     * @param  string $property
     * @return mixed
     */
    public function __get($property)
    {
        if ($property == 'content') {
            if (empty($this->_content)) {
                $this->_toItip();
                return $this->_content;
            }
        }

        throw new InvalidArgumentException('Invalid property access.');
    }

    /**
     * Output the data for this object in an array.
     *
     * @return array
     *   - type: (string)    The MIME type of the content.
     *   - subtype: (string) The MIME subtype.
     *   - name: (string)    The filename.
     *   - stream: (string)  The file data.
     */
    public function toArray()
    {
        return $this->_toItip();
    }

    /**
     * Set the METHOD parameter, used to help generate the PART-STAT attribute.
     *
     * @param string $method  The METHOD parameter.
     * @param string $class   The message class.
     */
    public function setMethod($method, $class = null)
    {
        $this->_method = $method;
        switch ($class) {
        case Horde_Compress_Tnef::IPM_MEETING_RESPONSE_TENT:
            $this->_partStat = self::PART_TENTATIVE;
            $this->_rsvp = false;
            break;
        case Horde_Compress_Tnef::IPM_MEETING_RESPONSE_NEG:
            $this->_partStat = self::PART_DECLINE;
            $this->_rsvp = false;
            break;
        case Horde_Compress_Tnef::IPM_MEETING_RESPONSE_POS:
            $this->_partStat = self::PART_ACCEPTED;
            $this->_rsvp = false;
            break;
        case Horde_Compress_Tnef::IPM_MEETING_REQUEST:
            $this->_partStat =self::PART_ACTION;
            $this->_rsvp = true;
            break;
        }
    }

    /**
     * Allow this object to set any TNEF attributes it needs to know about,
     * ignore any it doesn't care about.
     *
     * @param integer $attribute  The attribute descriptor.
     * @param mixed $value        The value from the MAPI stream.
     * @param integer $size       The byte length of the data, as reported by
     *                            the MAPI data.
     */
    public function setTnefAttribute($attribute, $value, $size)
    {
        switch ($attribute) {
        case Horde_Compress_Tnef::ABODY;
            $this->_description = $value;
            break;
        }
    }

    /**
     * Allow this object to set any MAPI attributes it needs to know about,
     * ignore any it doesn't care about.
     *
     * @param integer $type  The attribute type descriptor.
     * @param integer $name  The attribute name descriptor.
     * @param mixed $value   The value to set.
     *
     * @throws  Horde_Compress_Exception
     */
    public function setMapiAttribute($type, $name, $value, $ns = null)
    {
        // First check for pidTag* properties - these will have to namespace.
        // @todo look at just cocantenating the GUID with the pidLid in the
        // constants in H6?
        if (empty($ns)) {
            switch ($name) {
            case Horde_Compress_Tnef::MAPI_CONVERSATION_TOPIC:
                $this->_summary = $value;
                break;
            case Horde_Compress_Tnef::MAPI_SENT_REP_SMTP_ADDR:
                $this->_from = $value;
                break;
            case Horde_Compress_Tnef::MAPI_LAST_MODIFIER_NAME:
                // Sender SMTP is more appropriate, but not present in all
                // meeting request MAPI objects (it's normally taken form the
                // parent MAPI mail message object) Since this class doesn't
                // (currently) have access to the parent MIME
                // part (since this isn't necessarily from an email), this is the
                // only hope of obtaining an ORGANIZER.
                $this->_lastModifier = $value;
                break;
            case Horde_Compress_Tnef::MAPI_CREATION_TIME:
                try {
                    $this->_created = new Horde_Date(Horde_Mapi::filetimeToUnixtime($value), 'UTC');
                } catch (Horde_Mapi_Exception $e) {
                    throw new Horde_Compress_Exception($e);
                } catch (Horde_Date_Exception $e) {
                    throw new Horde_Compress_Exception($e);
                }
                break;
            case Horde_Compress_Tnef::MAPI_MODIFICATION_TIME:
                try {
                    $this->_modified = new Horde_Date(Horde_Mapi::filetimeToUnixtime($value), 'UTC');
                } catch (Horde_Mapi_Exception $e) {
                    throw new Horde_Compress_Exception($e);
                } catch (Horde_Date_Exception $e) {
                    throw new Horde_Compress_Exception($e);
                }
                break;
            case Horde_Compress_Tnef::MAPI_RESPONSE_REQUESTED:
                $this->_rsvp = $value;
                break;
            case Horde_Compress_Tnef::MAPI_TAG_RTF_COMPRESSED:
                // We may already have a description from the TNEF attBODY attribute
                if (empty($this->_description)) {
                    $this->_description = $value;
                }
                break;
            }
        } elseif ($ns == Horde_Compress_Tnef::PSETID_APPOINTMENT) {
            switch ($name) {
            case Horde_Compress_Tnef::MAPI_APPOINTMENT_LOCATION:
                $this->_location = $value;
                break;
            case Horde_Compress_Tnef::MAPI_APPOINTMENT_URL:
                $this->_url = $value;
                break;
            case Horde_Compress_Tnef::MAPI_APPOINTMENT_START_WHOLE:
                try {
                    $this->_startUtc = new Horde_Date(Horde_Mapi::filetimeToUnixtime($value), 'UTC');
                } catch (Horde_Mapi_Exception $e) {
                    throw new Horde_Compress_Exception($e);
                } catch (Horde_Date_Exception $e) {
                    throw new Horde_Compress_Exception($e);
                }
                break;
            case Horde_Compress_Tnef::MAPI_APPOINTMENT_END_WHOLE:
                try {
                    $this->_endUtc = new Horde_Date(Horde_Mapi::filetimeToUnixtime($value), 'UTC');
                } catch (Horde_Mapi_Exception $e) {
                    throw new Horde_Compress_Exception($e);
                } catch (Horde_Date_Exception $e) {
                    throw new Horde_Compress_Exception($e);
                }
                break;
            case Horde_Compress_Tnef::MAPI_APPOINTMENT_DURATION:
                $this->_duration = $value;
                break;
            case Horde_Compress_Tnef::MAPI_APPOINTMENT_SUBTYPE:
                $this->_allday = $value;
                break;
            case Horde_Compress_Tnef::MAPI_ORGANIZER_ALIAS:
                $this->_organizer = $value;
                break;
            case Horde_Compress_Tnef::MAPI_TO_ATTENDEES:
                // Don't even ask. Why, Microsoft, why??
                $value = str_replace(array('(', ')'), array('<', '>'), $value);
                $this->_requiredAttendees = $value;
                break;
            case Horde_Compress_Tnef::MAPI_APPOINTMENT_RECUR:
                $this->_recurrence['recur'] = $this->_parseRecurrence($value);
                break;
            case Horde_Compress_Tnef::MAPI_RECURRING:
                // ?? Reset $this->_recurrence?
                break;
            case Horde_Compress_Tnef::MAPI_RECURRENCE_TYPE:
                $this->_recurrence['type'] = $value;
                break;
            case Horde_Compress_Tnef::MAPI_RESPONSE_STATUS:
                // Don't think we need this, it seems more geared towards writing
                // a TNEF. Indicates the response status of an ATTENDEE. Putting
                // this here for reference, see MS-OXOCAL 2.2.1.11
                break;
            }
        } elseif ($ns == Horde_Compress_Tnef::PSETID_MEETING) {
            switch ($name) {
            case Horde_Compress_Tnef::MAPI_ENTRY_CLEANID:
            case Horde_Compress_Tnef::MAPI_ENTRY_UID:
                // Still not 100% sure about where a suitable UID comes from;
                // These attributes are all said to contain it, at various times.
                // The "Clean" UID is supposed to only be in appointments that
                // are exceptions to a recurring series, though I have a number
                // of examples where that is not the case. Also, in some cases
                // some of these attributes seem to be set here multiple times,
                // sometimes with non-empty and then empty values, so never set
                // self::$_uid if it is already set, or if $value is empty.
                if (empty($this->_uid) && !empty($value)) {
                    $this->_uid = Horde_Mapi::getUidFromGoid(bin2hex($value));
                }
                break;
            case Horde_Compress_Tnef::MAPI_MEETING_REQUEST_TYPE: //pset
                $this->_type = $value;
                break;
            }
        } else {
            $this->_logger->notice(sprintf('Unknown namespace GUID: %s', $ns));
        }
    }

    /**
     * Parse recurrence properties.
     *
     * @param string  $value MAPI stream
     *
     * @return Horde_Date_Recurrence
     * @throws  Horde_Compress_Exception
     */
    protected function _parseRecurrence($value)
    {
        $deleted = $modified = array();

        // both are 0x3004 (version strings);
        $this->_geti($value, 16);
        $this->_geti($value, 16);

        $freq = $this->_geti($value, 16);
        $pattern = $this->_geti($value, 16);
        $calendarType = $this->_geti($value, 16);
        $firstDt = $this->_geti($value, 32);
        $period = $this->_geti($value, 32);

        // Only used for tasks, otherwise value must be zero.
        $flag = $this->_geti($value, 32);

        // TypeSpecific field
        switch ($pattern) {
        case Horde_Compress_Tnef::PATTERN_DAY:
            // Nothing here to see, move along.
            break;
        case Horde_Compress_Tnef::PATTERN_WEEK:
            // Bits: 0/unused, 1/Saturday, 2/Friday, 3/Thursday, 4/Wednesday,
            // 5/Tuesday, 6/Monday, 7/Sunday.
            $day = $this->_geti($value, 8);
            // ??
            $this->_geti($value, 24);
            break;
        case Horde_Compress_Tnef::PATTERN_MONTH:
        case Horde_Compress_Tnef::PATTERN_MONTH_END:
            // Day of month on which the recurrence falls.
            $day = $this->_geti($value, 32);
            break;
        case Horde_Compress_Tnef::PATTERN_MONTH_NTH:
            // Bits: 0/unused, 1/Saturday, 2/Friday, 3/Thursday, 4/Wednesday,
            // 5/Tuesday, 6/Monday, 7/Sunday.
            // For Nth Weekday of month
            $day = $this->_geti($value, 8);
            $this->_geti($value, 24);
            $n = $this->_geti($value, 32);
            break;
        }
        $end = $this->_geti($value, 32);
        $count = $this->_geti($value, 32);
        $fdow = $this->_geti($value, 32);
        $deletedCount = $this->_geti($value, 32);
        for ($i = 0; $i < $deletedCount; $i++) {
            $deleted[] = $this->_geti($value, 32);
        }
        $modifiedCount = $this->_geti($value, 32);
        for ($i = 0; $i < $modifiedCount; $i++) {
            $modified[] = $this->_geti($value, 32);
        }

        // What Timezone are these in?
        try {
            $startDate = new Horde_Date(Horde_Mapi::filetimeToUnixtime($this->_geti($value, 32)));
            $endDate = new Horde_Date(Horde_Mapi::filetimeToUnixtime($this->_geti($value, 32)));
        } catch (Horde_Mapi_Exception $e) {
            throw new Horde_Compress_Exception($e);
        } catch (Horde_Date_Exception $e) {
            throw new Horde_Compress_Exception($e);
        }

        $rrule = new Horde_Date_Recurrence($startDate);
        switch ($pattern) {
        case Horde_Compress_Tnef::PATTERN_DAY:
            $rrule->setRecurType(Horde_Date_Recurrence::RECUR_DAILY);
            break;
        case Horde_Compress_Tnef::PATTERN_WEEK:
            $rrule->setRecurType(Horde_Date_Recurrence::RECUR_WEEKLY);
            break;
        case Horde_Compress_Tnef::PATTERN_MONTH:
        case Horde_Compress_Tnef::PATTERN_MONTH_END:
            $rrule->setRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_DATE);
            break;
        case Horde_Compress_Tnef::PATTERN_MONTH_NTH:
            $rrule->setRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY);
            break;
        default:
            if ($freq == Horde_Compress_Tnef::RECUR_YEARLY) {
                $rrule->setRecurType(Horde_Date_Recurrence::RECUR_YEARLY);
            }
        }

        switch ($end) {
        case Horde_Compress_Tnef::RECUR_END_N:
            $rrule->setRecurCount($count);
            break;
        case Horde_Compress_Tnef::RECUR_END_DATE:
            $rrule->setRecurEnd($endDate);
            break;
        }

        return $rrule;
    }

    /**
     * Generate an iTip from embedded TNEF MEETING data.
     *
     * @return array  see @self::toArray().
     */
    protected function _toItip()
    {
        $iCal = new Horde_Icalendar();

        // METHOD
        if ($this->_type) {
            switch ($this->_type) {
            case Horde_Compress_Tnef::MAPI_MEETING_INITIAL:
            case Horde_Compress_Tnef::MAPI_MEETING_FULL_UPDATE:
                $this->_method = 'REQUEST';
                break;
            case Horde_Compress_Tnef::MAPI_MEETING_INFO:
                $this->_method = 'PUBLISH';
                break;
            }
        }
        $iCal->setAttribute('METHOD', $this->_method);

        // VEVENT
        $vEvent = Horde_Icalendar::newComponent('vevent', $iCal);
        if (empty($this->_endUtc)) {
            return;
        }
        $end = clone $this->_endUtc;
        $end->sec++;
        if ($this->_allday) {
            $vEvent->setAttribute('DTSTART', $this->_startUtc, array('VALUE' => 'DATE'));
            $vEvent->setAttribute('DTEND', $end, array('VALUE' => 'DATE'));
        } else {
            $vEvent->setAttribute('DTSTART', $this->_startUtc);
            $vEvent->setAttribute('DTEND', $end);
        }
        $vEvent->setAttribute('DTSTAMP', $_SERVER['REQUEST_TIME']);
        $vEvent->setAttribute('UID', $this->_uid);
        if ($this->_created) {
            $vEvent->setAttribute('CREATED', $this->_created);
        }
        if ($this->_modified) {
            $vEvent->setAttribute('LAST-MODIFIED', $this->_modified);
        }

        // SUMMARY and DESCRIPTION
        $vEvent->setAttribute('SUMMARY', $this->_summary);
        if ($this->_description) {
            $vEvent->setAttribute('DESCRIPTION', trim($this->_description));
        }

        // ORGANIZER
        if (!$this->_organizer && $this->_lastModifier) {
            $email = $this->_lastModifier;
        } else if ($this->_organizer) {
            $email = $this->_organizer;
        }
        if (!empty($email)) {
            $vEvent->setAttribute('ORGANIZER', 'mailto:' . $email);
        }


        // ATTENDEE
        if (empty($this->_requiredAttendees) && $this->_method == 'REPLY') {
            $this->_requiredAttendees = $this->_from;
        }

        if (!empty($this->_requiredAttendees)) {
            $list = new Horde_Mail_Rfc822_List($this->_requiredAttendees);
            foreach ($list as $email) {
                $params = array('ROLE' => 'REQ-PARTICIPANT');
                if (!empty($this->_partStat)) {
                    $params['PARTSTAT'] = $this->_partStat;
                }
                if ($this->_rsvp) {
                    $params['RSVP'] = 'TRUE';
                }
                $vEvent->setAttribute('ATTENDEE', $email->bare_address, $params);
            }
        }

        // LOCATION
        if ($this->_location) {
            $vEvent->setAttribute('LOCATION', $this->_location);
        }

        // URL
        if ($this->_url) {
            $vEvent->setAttribute('URL', $this->_url);
        }

        // RECUR
        if (!empty($this->_recurrence['recur'])) {
            $rrule = $this->_recurrence['recur']->toRRule20($iCal);
            $vEvent->setAttribute('RRULE', $rrule);
        }
        $iCal->addComponent($vEvent);
        $this->_content = $iCal->exportvCalendar();

        return array(
            'type'    => 'text',
            'subtype' => 'calendar',
            'name'    => $this->_summary,
            'stream'  => $this->_content
        );
    }

}