diff options
author | Anna Larch <anna@nextcloud.com> | 2021-11-03 18:46:11 +0300 |
---|---|---|
committer | Anna Larch <anna@nextcloud.com> | 2021-11-04 14:52:55 +0300 |
commit | bc68108f2a2d2686323d2431ad908e602bc9f090 (patch) | |
tree | 147d26b14f4a65d5bd4180b31984d499c8e53426 | |
parent | c6429e6cd19c57582364338362e543580821cf99 (diff) |
Fix missing calendar path for public write on Calendars
Signed-off-by: Anna Larch <anna@nextcloud.com>
-rw-r--r-- | apps/dav/lib/CalDAV/CalendarImpl.php | 11 | ||||
-rw-r--r-- | build/psalm-baseline.xml | 5 |
2 files changed, 15 insertions, 1 deletions
diff --git a/apps/dav/lib/CalDAV/CalendarImpl.php b/apps/dav/lib/CalDAV/CalendarImpl.php index ed37c0a745d..d45e12234d1 100644 --- a/apps/dav/lib/CalDAV/CalendarImpl.php +++ b/apps/dav/lib/CalDAV/CalendarImpl.php @@ -33,6 +33,7 @@ use OCP\Calendar\Exceptions\CalendarException; use OCP\Calendar\ICreateFromString; use OCP\Constants; use Sabre\DAV\Exception\Conflict; +use function Sabre\Uri\split as uriSplit; class CalendarImpl implements ICreateFromString { @@ -145,11 +146,19 @@ class CalendarImpl implements ICreateFromString { // so set the custom principal here $plugin->setCurrentPrincipal($this->calendar->getPrincipalURI()); + if (empty($this->calendarInfo['uri'])) { + throw new CalendarException('Could not write to calendar as URI parameter is missing'); + } + + // Build full calendar path + [, $user] = uriSplit($this->calendar->getPrincipalURI()); + $fullCalendarFilename = sprintf('calendars/%s/%s/%s', $user, $this->calendarInfo['uri'], $name); + $stream = fopen('php://memory', 'rb+'); fwrite($stream, $calendarData); rewind($stream); try { - $server->server->createFile($name, $stream); + $server->server->createFile($fullCalendarFilename, $stream); } catch (Conflict $e) { throw new CalendarException('Could not create new calendar event: ' . $e->getMessage(), 0, $e); } finally { diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index bdcdeb5796a..001e352eadc 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -232,6 +232,11 @@ <code>calendarSearch</code> </UndefinedInterfaceMethod> </file> + <file src="apps/dav/lib/CalDAV/CalendarImpl.php"> + <UndefinedFunction occurrences="1"> + <code>uriSplit($this->calendar->getPrincipalURI())</code> + </UndefinedFunction> + </file> <file src="apps/dav/lib/CalDAV/CalendarRoot.php"> <ParamNameMismatch occurrences="1"> <code>$principal</code> |