-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Fix/caldav option forgiving #62090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix/caldav option forgiving #62090
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2325,7 +2325,7 @@ public function search( | |
| } | ||
|
|
||
| $calendarObjects = array_map(function ($o) use ($options) { | ||
| $calendarData = Reader::read($o['calendardata']); | ||
| $calendarData = Reader::read($o['calendardata'], $this->getReaderOptions()); | ||
|
|
||
| // Expand recurrences if an explicit time range is requested | ||
| if ($calendarData instanceof VCalendar | ||
|
|
@@ -3392,7 +3392,7 @@ public function restoreChanges(int $calendarId, int $calendarType = self::CALEND | |
| * @return array | ||
| */ | ||
| public function getDenormalizedData(string $calendarData): array { | ||
| $vObject = Reader::read($calendarData); | ||
| $vObject = Reader::read($calendarData, $this->getReaderOptions()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
| $vEvents = []; | ||
| $componentType = null; | ||
| $component = null; | ||
|
|
@@ -3843,7 +3843,13 @@ public function moveCalendar($uriName, $uriOrigin, $uriDestination, $newUriName | |
| * @return VCalendar | ||
| */ | ||
| protected function readCalendarData($objectData) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
| return Reader::read($objectData); | ||
| return Reader::read($objectData, $this->getReaderOptions()); | ||
| } | ||
|
|
||
| private function getReaderOptions(): int { | ||
| return $this->config->getSystemValueBool('dav.forgiving_ical_parser', false) | ||
| ? Reader::OPTION_FORGIVING | ||
| : 0; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| use OCA\DAV\CalDAV\CalDavBackend; | ||
| use OCA\DAV\CalDAV\CalendarImpl; | ||
| use OCP\Calendar\CalendarImportOptions; | ||
| use OCP\IConfig; | ||
| use Sabre\VObject\Component\VCalendar; | ||
| use Sabre\VObject\Node; | ||
| use Sabre\VObject\Reader; | ||
|
|
@@ -26,6 +27,7 @@ class ImportService { | |
|
|
||
| public function __construct( | ||
| private CalDavBackend $backend, | ||
| private IConfig $config, | ||
| ) { | ||
| } | ||
|
|
||
|
|
@@ -83,7 +85,7 @@ public function importText($source): Generator { | |
| foreach ($structure['VTIMEZONE'] as $tid => $collection) { | ||
| $instance = $collection[0]; | ||
| $sObjectContents = $importer->extract((int)$instance[2], (int)$instance[3]); | ||
| $vObject = Reader::read($sObjectPrefix . $sObjectContents . $sObjectSuffix); | ||
| $vObject = Reader::read($sObjectPrefix . $sObjectContents . $sObjectSuffix, $this->getReaderOptions()); | ||
| $timezones[$tid] = clone $vObject->VTIMEZONE; | ||
| } | ||
| // calendar components | ||
|
|
@@ -98,7 +100,7 @@ public function importText($source): Generator { | |
| $sObjectContents .= $importer->extract($instance[2], $instance[3]); | ||
| } | ||
| /** @var VCalendar $vObject */ | ||
| $vObject = Reader::read($sObjectPrefix . $sObjectContents . $sObjectSuffix); | ||
| $vObject = Reader::read($sObjectPrefix . $sObjectContents . $sObjectSuffix, $this->getReaderOptions()); | ||
| // add time zones to object | ||
| foreach ($this->findTimeZones($vObject) as $zone) { | ||
| if (isset($timezones[$zone])) { | ||
|
|
@@ -342,4 +344,10 @@ private function componentValidate(VCalendar $vObject, bool $repair, int $level) | |
|
|
||
| return $result; | ||
| } | ||
|
|
||
| private function getReaderOptions(): int { | ||
| return $this->config->getSystemValueBool('dav.forgiving_ical_parser', false) | ||
| ? Reader::OPTION_FORGIVING | ||
| : 0; | ||
| } | ||
| } | ||
|
Comment on lines
+348
to
353
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be an import option, not a system configuration value
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, that makes sense, Should the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll the issue you linked specifically states that the issue is with importing. Not with general PUT requests from a specific client, so I would not add a plugin to validate the events. Also there is a PR that will fix a lot of this in the future. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed, once the data is read the first time with the forgiving flag, it should not need to be read with this flag.