diff --git a/README.md b/README.md index 2842fe5..9c9337a 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ Here is a list of clients tested with KaraDAV: * [FUSE webdavfs](https://github.com/miquels/webdavfs) is **recommended** for Linux * davfs2 is NOT recommended: it is very slow, and it is using a local cache, meaning changing a file locally may not be synced to the server for a few minutes, leading to things getting out of sync. If you have to use it, at least disable locks, by setting `use_locks=0` in the config. * Microsoft Windows native webclient (also called 'MiniRedir') is notoriously bad. We tested it successfully on Windows 10, but it is recommended to use [CyberDuck](https://cyberduck.io/download/) or [WinSCP](https://winscp.net/) instead, both are free software. +* CyberDuck (Windows) version 8.5.0 * Dolphin (KDE) * Thunar (GTK/GNOME) * [rclone](https://rclone.org/webdav/) on Linux @@ -102,7 +103,12 @@ This might get supported in future (maybe): * Probably: [NextCloud Trashbin](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/WebDAV/trashbin.html) * Maybe: [NextCloud sharing](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-share-api.html) -* Maybe: NextCloud files versioning (see [API](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/WebDAV/versions.html), [versioning pattern](https://docs.nextcloud.com/server/latest/user_manual/en/files/version_control.html), [code](https://github.com/nextcloud/server/blob/master/apps/files_versions/lib/Storage.php)) +* Maybe: NextCloud files versioning + * [NextCloud API](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/WebDAV/versions.html) + * [NextCloud versioning pattern](https://docs.nextcloud.com/server/latest/user_manual/en/files/version_control.html) + * [NextCloud implementation](https://github.com/nextcloud/server/blob/master/apps/files_versions/lib/Storage.php)) + * [Mercurial revlog](https://www.mercurial-scm.org/wiki/Revlog) + * [Eric Sink on SCM versioning](https://ericsink.com/scm/scm_repositories.html) This probably won't get supported anytime soon: diff --git a/config.dist.php b/config.dist.php index 7c36ef1..8939039 100644 --- a/config.dist.php +++ b/config.dist.php @@ -22,17 +22,12 @@ const DB_FILE = __DIR__ . '/data/db.sqlite'; /** * WWW_URL is the complete URL of the root of this server * - * This code auto-detects it as well as it can - * But you may have to assign something static instead, for example: + * If you don't define it, KaraDAV will try to auto-detects it as well as it can. + * But you may have to assign something static instead if that fails, for example: * * const WWW_URL = 'https://dav.website.example/'; */ -$https = (!empty($_SERVER['HTTPS']) || $_SERVER['SERVER_PORT'] == 443) ? 's' : ''; -$name = $_SERVER['SERVER_NAME']; -$port = !in_array($_SERVER['SERVER_PORT'], [80, 443]) ? ':' . $_SERVER['SERVER_PORT'] : ''; -$root = '/'; - -define('KaraDAV\WWW_URL', sprintf('http%s://%s%s%s', $https, $name, $port, $root)); +#const WWW_URL = 'http://karadav.localhost/'; /** * WOPI client discovery URL diff --git a/doc/CHANGES.md b/doc/CHANGES.md new file mode 100644 index 0000000..9589ea9 --- /dev/null +++ b/doc/CHANGES.md @@ -0,0 +1,16 @@ +# 0.3.2 + +* Fix issue with Cyberduck (Windows) +* Move auto-detection code for WWW_URL outside of config.local.php, if WWW_URL is not defined, then KaraDAV will trigger auto-detection + +# 0.3.1 + +* Fix issue with NextCloud direct URLs crashing + +# 0.3.0 + +* Fix typos +* Fix security issues +* Add list of tested clients in README +* Add systemd service file +* Don't store WOPI tokens in database, instead use a time-limited HMAC hash diff --git a/lib/KD2/WebDAV/Server.php b/lib/KD2/WebDAV/Server.php index 2783cb1..6f2e866 100644 --- a/lib/KD2/WebDAV/Server.php +++ b/lib/KD2/WebDAV/Server.php @@ -606,17 +606,23 @@ class Server // Find all properties // Allow for empty namespace, see Litmus FAQ for propnullns // https://github.com/tolsen/litmus/blob/master/FAQ - preg_match_all('!<(?:([\w-]+):)([\w-]+)|<([\w-]+)[^>]*xmlns="([^"]*)"!', $match[2], $match, PREG_SET_ORDER); + preg_match_all('!<([\w-]+)[^>]*xmlns="([^"]*)"|<(?:([\w-]+):)?([\w-]+)!', $match[2], $match, PREG_SET_ORDER); $properties = []; foreach ($match as $found) { - $url = $found[4] ?? (array_search($found[1], $ns) ?: $default_ns); - $name = isset($found[4]) ? $found[3] : $found[2]; + if (isset($found[4])) { + $url = array_search($found[3], $ns) ?: $default_ns; + $name = $found[4]; + } + else { + $url = $found[2]; + $name = $found[1]; + } $properties[$url . ':' . $name] = [ 'name' => $name, - 'ns_alias' => $found[1], + 'ns_alias' => $found[3] ?: null, 'ns_url' => $url, ]; } diff --git a/www/_inc.php b/www/_inc.php index 639aae0..ecfc4ea 100644 --- a/www/_inc.php +++ b/www/_inc.php @@ -46,6 +46,15 @@ if (!defined('KaraDAV\SECRET_KEY')) { } } +if (!defined('KaraDAV\WWW_URL')) { + $https = (!empty($_SERVER['HTTPS']) || $_SERVER['SERVER_PORT'] == 443) ? 's' : ''; + $name = $_SERVER['SERVER_NAME']; + $port = !in_array($_SERVER['SERVER_PORT'], [80, 443]) ? ':' . $_SERVER['SERVER_PORT'] : ''; + $root = '/'; + + define('KaraDAV\WWW_URL', sprintf('http%s://%s%s%s', $https, $name, $port, $root)); +} + // Init database if (!file_exists(DB_FILE)) { $db = DB::getInstance();