[FEATURE] Add config and use composer autoloader.

We use composer already to install SabreDAV. Include config
composer.(json|lock) to install and manage more dependencies
in future.
Also provide PSR-4 autoloading for our namespaced classes, e.g.
"Zotlabs\". To regenerate autoloader maps use:
$ composer install --optimize-autoloader --no-dev

We could also remove the whole vendor/ folder from our repository, but
that would need changes in deployment and how to install hubs and needs
more discussion first.
This commit is contained in:
Klaus Weidenbach
2016-10-17 23:26:48 +02:00
parent 17091bd38c
commit 745515b11f
51 changed files with 2097 additions and 490 deletions

View File

@@ -3,14 +3,9 @@ php:
- 5.5
- 5.6
- 7
- hhvm
sudo: false
matrix:
allow_failures:
- php: hhvm
script:
- phpunit --configuration tests/phpunit.xml
- ./bin/sabre-cs-fixer fix . --dry-run --diff

View File

@@ -1,6 +1,19 @@
ChangeLog
=========
4.1.1 (2016-07-15)
------------------
* #327: Throwing `InvalidDataException` in more cases where invalid iCalendar
dates and times were provided. (@rsto)
* #331: Fix dealing with multiple overridden instances falling on the same
date/time (@afedyk-sugarcrm).
* #333: Fix endless loop on invalid `BYMONTH` values in recurrence.
(@PHPGangsta)
* #339: Fixed a few `validate()` results when repair is off. (@PHPGangsta)
* #338: Stripping invalid `BYMONTH=` rules during `validate()` (@PHPGangsta)
* #336: Fix incorrect `BYSECOND=` validation. (@PHPGangsta)
4.1.0 (2016-04-06)
------------------
@@ -130,6 +143,20 @@ ChangeLog
and `IntegerValue` to allow PHP 7 compatibility.
3.5.3 (????-??-??)
------------------
* #331: Fix dealing with multiple overridden instances falling on the same
date/time (@afedyk-sugarcrm).
3.5.2 (2016-04-24)
-----------------
* #312: Backported a fix related to iTip processing of events with timezones,
without a master event.
3.5.1 (2016-04-06)
------------------

0
vendor/sabre/vobject/bin/bench.php vendored Normal file → Executable file
View File

0
vendor/sabre/vobject/bin/fetch_windows_zones.php vendored Normal file → Executable file
View File

2
vendor/sabre/vobject/bin/generateicalendardata.php vendored Normal file → Executable file
View File

@@ -29,7 +29,7 @@ include __DIR__ . '/../vendor/autoload.php';
fwrite(STDERR, "Generating " . $events . " events\n");
$currentDate = new DateTime('-' . round($events / 2) . ' days');
$currentDate = new DateTime('-' . round($events / 2) . ' days');
$calendar = new VObject\Component\VCalendar();

2
vendor/sabre/vobject/bin/mergeduplicates.php vendored Normal file → Executable file
View File

@@ -157,7 +157,7 @@ while ($vcard = $splitter->getNext()) {
// echo $newProp->serialize() . " does not appear in earlier vcard!\n";
$stats['Error']++;
if ($debug) fwrite($debug, "Missing '" . $newProp->name . "' property in duplicate. Earlier vcard:\n" . $collectedNames[$fn]->serialize() . "\n\nLater:\n" . $vcard->serialize() . "\n\n");
if ($debug) fwrite($debug, "Missing '" . $newProp->name . "' property in duplicate. Earlier vcard:\n" . $collectedNames[$fn]->serialize() . "\n\nLater:\n" . $vcard->serialize() . "\n\n");
$vcard->destroy();
continue 2;

88
vendor/sabre/vobject/composer.json vendored Normal file
View File

@@ -0,0 +1,88 @@
{
"name": "sabre/vobject",
"description" : "The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects",
"keywords" : [
"iCalendar",
"iCal",
"vCalendar",
"vCard",
"jCard",
"jCal",
"ics",
"vcf",
"xCard",
"xCal",
"freebusy",
"recurrence",
"availability",
"rfc2425",
"rfc2426",
"rfc2739",
"rfc4770",
"rfc5545",
"rfc5546",
"rfc6321",
"rfc6350",
"rfc6351",
"rfc6474",
"rfc6638",
"rfc6715",
"rfc6868"
],
"homepage" : "http://sabre.io/vobject/",
"license" : "BSD-3-Clause",
"require" : {
"php" : ">=5.5",
"ext-mbstring" : "*",
"sabre/xml" : "~1.1"
},
"require-dev" : {
"phpunit/phpunit" : "*",
"sabre/cs" : "~0.0.3"
},
"suggest" : {
"hoa/bench" : "If you would like to run the benchmark scripts"
},
"authors" : [
{
"name" : "Evert Pot",
"email" : "me@evertpot.com",
"homepage" : "http://evertpot.com/",
"role" : "Developer"
},
{
"name" : "Dominik Tobschall",
"email" : "dominik@fruux.com",
"homepage" : "http://tobschall.de/",
"role" : "Developer"
},
{
"name" : "Ivan Enderlin",
"email" : "ivan.enderlin@hoa-project.net",
"homepage" : "http://mnt.io/",
"role" : "Developer"
}
],
"support" : {
"forum" : "https://groups.google.com/group/sabredav-discuss",
"source" : "https://github.com/fruux/sabre-vobject"
},
"autoload" : {
"psr-4" : {
"Sabre\\VObject\\" : "lib/"
}
},
"bin" : [
"bin/vobject",
"bin/generate_vcards"
],
"extra" : {
"branch-alias" : {
"dev-master" : "4.0.x-dev"
}
},
"config" : {
"bin-dir" : "bin"
}
}

View File

@@ -53,8 +53,7 @@ class VTimeZone extends VObject\Component {
'LAST-MODIFIED' => '?',
'TZURL' => '?',
// At least 1 STANDARD or DAYLIGHT must appear, or more. But both
// cannot appear in the same VTIMEZONE.
// At least 1 STANDARD or DAYLIGHT must appear.
//
// The validator is not specific yet to pick this up, so these
// rules are too loose.

View File

@@ -43,7 +43,12 @@ class DateTimeParser {
if ($matches[7] === 'Z' || is_null($tz)) {
$tz = new DateTimeZone('UTC');
}
$date = new DateTimeImmutable($matches[1] . '-' . $matches[2] . '-' . $matches[3] . ' ' . $matches[4] . ':' . $matches[5] . ':' . $matches[6], $tz);
try {
$date = new DateTimeImmutable($matches[1] . '-' . $matches[2] . '-' . $matches[3] . ' ' . $matches[4] . ':' . $matches[5] . ':' . $matches[6], $tz);
} catch (\Exception $e) {
throw new InvalidDataException('The supplied iCalendar datetime value is incorrect: ' . $dt);
}
return $date;
@@ -70,7 +75,11 @@ class DateTimeParser {
$tz = new DateTimeZone('UTC');
}
$date = new DateTimeImmutable($matches[1] . '-' . $matches[2] . '-' . $matches[3], $tz);
try {
$date = new DateTimeImmutable($matches[1] . '-' . $matches[2] . '-' . $matches[3], $tz);
} catch (\Exception $e) {
throw new InvalidDataException('The supplied iCalendar date value is incorrect: ' . $date);
}
return $date;

View File

@@ -579,7 +579,7 @@ abstract class Property extends Node {
// Checking if the propertyname does not contain any invalid bytes.
if (!preg_match('/^([A-Z0-9-]+)$/', $this->name)) {
$warnings[] = [
'level' => 1,
'level' => $options & self::REPAIR ? 1 : 3,
'message' => 'The propertyname: ' . $this->name . ' contains invalid characters. Only A-Z, 0-9 and - are allowed',
'node' => $this,
];
@@ -599,7 +599,7 @@ abstract class Property extends Node {
if ($this->root->getDocumentType() === Document::VCARD40) {
$warnings[] = [
'level' => 1,
'level' => 3,
'message' => 'ENCODING parameter is not valid in vCard 4.',
'node' => $this
];
@@ -623,7 +623,7 @@ abstract class Property extends Node {
}
if ($allowedEncoding && !in_array(strtoupper($encoding), $allowedEncoding)) {
$warnings[] = [
'level' => 1,
'level' => 3,
'message' => 'ENCODING=' . strtoupper($encoding) . ' is not valid for this document type.',
'node' => $this
];

View File

@@ -260,21 +260,39 @@ class Recur extends Property {
foreach ($values as $key => $value) {
if (empty($value)) {
if ($value === '') {
$warnings[] = [
'level' => $repair ? 3 : 1,
'level' => $repair ? 1 : 3,
'message' => 'Invalid value for ' . $key . ' in ' . $this->name,
'node' => $this
];
if ($repair) {
unset($values[$key]);
}
} elseif ($key == 'BYMONTH') {
$byMonth = (array)$value;
foreach ($byMonth as $i => $v) {
if (!is_numeric($v) || (int)$v < 1 || (int)$v > 12) {
$warnings[] = [
'level' => $repair ? 1 : 3,
'message' => 'BYMONTH in RRULE must have value(s) between 1 and 12!',
'node' => $this
];
if ($repair) {
if (is_array($value)) {
unset($values[$key][$i]);
} else {
unset($values[$key]);
}
}
}
}
}
}
if (!isset($values['FREQ'])) {
$warnings[] = [
'level' => $repair ? 3 : 1,
'level' => $repair ? 1 : 3,
'message' => 'FREQ is required in ' . $this->name,
'node' => $this
];

View File

@@ -397,7 +397,7 @@ class Text extends Property {
if (count($parts) < $minimum) {
$warnings[] = [
'level' => $options & self::REPAIR ? 1 : 3,
'message' => 'The ' . $this->name . ' property must have at least ' . $minimum . ' values. It only has ' . count($parts),
'message' => 'The ' . $this->name . ' property must have at least ' . $minimum . ' values. It only has ' . count($parts),
'node' => $this,
];
if ($options & self::REPAIR) {

View File

@@ -325,7 +325,7 @@ class EventIterator implements \Iterator {
$index = [];
foreach ($this->overriddenEvents as $key => $event) {
$stamp = $event->DTSTART->getDateTime($this->timeZone)->getTimeStamp();
$index[$stamp] = $key;
$index[$stamp][] = $key;
}
krsort($index);
$this->counter = 0;
@@ -372,8 +372,9 @@ class EventIterator implements \Iterator {
// overridden event may cut ahead.
if ($this->overriddenEventsIndex) {
$offset = end($this->overriddenEventsIndex);
$offsets = end($this->overriddenEventsIndex);
$timestamp = key($this->overriddenEventsIndex);
$offset = end($offsets);
if (!$nextDate || $timestamp < $nextDate->getTimeStamp()) {
// Overridden event comes first.
$this->currentOverriddenEvent = $this->overriddenEvents[$offset];
@@ -383,7 +384,10 @@ class EventIterator implements \Iterator {
$this->currentDate = $this->currentOverriddenEvent->DTSTART->getDateTime($this->timeZone);
// Ensuring that this item will only be used once.
array_pop($this->overriddenEventsIndex);
array_pop($this->overriddenEventsIndex[$timestamp]);
if (!$this->overriddenEventsIndex[$timestamp]) {
array_pop($this->overriddenEventsIndex);
}
// Exit point!
return;
@@ -451,7 +455,7 @@ class EventIterator implements \Iterator {
/**
* Overridden event index.
*
* Key is timestamp, value is the index of the item in the $overriddenEvent
* Key is timestamp, value is the list of indexes of the item in the $overriddenEvent
* property.
*
* @var array

View File

@@ -718,6 +718,11 @@ class RRuleIterator implements Iterator {
case 'BYMONTH' :
$this->byMonth = (array)$value;
foreach ($this->byMonth as $byMonth) {
if (!is_numeric($byMonth) || (int)$byMonth < 1 || (int)$byMonth > 12) {
throw new InvalidDataException('BYMONTH in RRULE must have value(s) betweeen 1 and 12!');
}
}
break;
case 'BYSETPOS' :

View File

@@ -240,10 +240,10 @@ class TimeZoneUtil {
if (!is_null(self::$map)) return;
self::$map = array_merge(
include __DIR__ . '/timezonedata/windowszones.php',
include __DIR__ . '/timezonedata/lotuszones.php',
include __DIR__ . '/timezonedata/exchangezones.php',
include __DIR__ . '/timezonedata/php-workaround.php'
include __DIR__ . '/timezonedata/windowszones.php',
include __DIR__ . '/timezonedata/lotuszones.php',
include __DIR__ . '/timezonedata/exchangezones.php',
include __DIR__ . '/timezonedata/php-workaround.php'
);
}
@@ -260,7 +260,7 @@ class TimeZoneUtil {
* @return array
*/
static function getIdentifiersBC() {
return include __DIR__ . '/timezonedata/php-bc.php';
return include __DIR__ . '/timezonedata/php-bc.php';
}
}

View File

@@ -14,6 +14,6 @@ class Version {
/**
* Full version number.
*/
const VERSION = '4.1.0';
const VERSION = '4.1.1';
}