From 52caa307fda8fbd636022b8f43e2f1adbda5454a Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 30 Nov 2022 13:29:22 +0100 Subject: [PATCH] Fix error when creating a DAV contacts folder --- plugins/libkolab/lib/kolab_storage_dav.php | 19 ++++++++++++++++++- .../libkolab/lib/kolab_storage_dav_folder.php | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/libkolab/lib/kolab_storage_dav.php b/plugins/libkolab/lib/kolab_storage_dav.php index 1837ff0a..7dd27da2 100644 --- a/plugins/libkolab/lib/kolab_storage_dav.php +++ b/plugins/libkolab/lib/kolab_storage_dav.php @@ -168,6 +168,23 @@ class kolab_storage_dav return kolab_storage::get_freebusy_url($email, $start, $end); } + /** + * Creates folder ID from a DAV folder location and server URI. + * + * @param string $uri DAV server location + * @param string $href Folder location + * + * @return string Folder ID string + */ + public static function folder_id($uri, $href) + { + if (($rootPath = parse_url($uri, PHP_URL_PATH)) && strpos($href, $rootPath) === 0) { + $href = substr($href, strlen($rootPath)); + } + + return md5(rtrim($uri, '/') . '/' . trim($href, '/')); + } + /** * Deletes a folder * @@ -264,7 +281,7 @@ class kolab_storage_dav $result = $this->dav->folderCreate($location, $type, $prop); if ($result !== false) { - $result = md5($this->dav->url . '/' . $location); + $result = self::folder_id($this->dav->url, $location); } } diff --git a/plugins/libkolab/lib/kolab_storage_dav_folder.php b/plugins/libkolab/lib/kolab_storage_dav_folder.php index adfa1d88..c1141144 100644 --- a/plugins/libkolab/lib/kolab_storage_dav_folder.php +++ b/plugins/libkolab/lib/kolab_storage_dav_folder.php @@ -34,7 +34,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder $this->attributes = $attributes; $this->href = $this->attributes['href']; - $this->id = md5($dav->url . '/' . $this->href); + $this->id = kolab_storage_dav::folder_id($dav->url, $this->href); $this->dav = $dav; $this->valid = true;