Fix issue with Cyberduck, move WWW_URL auto-detection outside of config file, add CHANGES log

This commit is contained in:
bohwaz 2022-11-13 18:35:31 +01:00
parent 3d1af68671
commit 3641b1d2e1
5 changed files with 45 additions and 13 deletions

View file

@ -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:

View file

@ -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

16
doc/CHANGES.md Normal file
View file

@ -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

View file

@ -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,
];
}

View file

@ -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();