I have a fresh installation of Nextcloud 10.0.1.
In the web-ui I can't create any files / folders with spaces in the name. Neither can I rename or delete any existing files or folders with a space. The existing files with spaces were added on the command line.
I'm running Ubuntu 16.04. Apache 2.4, php 7.4 (through php-fpm). I've had this problem both with mysql and postgresql as the database.
To reproduce this:
The result is no folder is created and an error is left in the log.
The error from the logs is:
"Message":"Requested uri
(\/cloud\/remote.php\/webdav\/New%20folder) is out of base uri
(\/remote.php\/webdav\/)","Exception":"LogicException","Code":0,"Trace":"#0
\/srv\/apache\/www.example.com\/content\/cloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(1225):
Sabre\\HTTP\\Request->getPath()\n#1
\/srv\/apache\/www.example.com\/content\/cloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(454):
Sabre\\DAV\\Server->checkPreconditions(Object(Sabre\\HTTP\\Request),
Object(Sabre\\HTTP\\Response))\n#2
\/srv\/apache\/www.example.com\/content\/cloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(248):
Sabre\\DAV\\Server->invokeMethod(Object(Sabre\\HTTP\\Request),
Object(Sabre\\HTTP\\Response))\n#3
\/srv\/apache\/www.example.com\/content\/cloud\/apps\/dav\/appinfo\/v1\/webdav.php(60):
Sabre\\DAV\\Server->exec()\n#4
\/srv\/apache\/www.example.com\/content\/cloud\/remote.php(165):
require_once('\/srv\/apache\/www...')\n#5
{main}","File":"\/srv\/apache\/www.example.com\/content\/cloud\/3rdparty\/sabre\/http\/lib\/Request.php","Line":214,"User":"philip"}
For PHP I have installed:
php-common 1:35ubuntu6
php-curl 1:7.0+35ubuntu6
php-fpm 1:7.0+35ubuntu6
php-gd 1:7.0+35ubuntu6
php-mbstring 1:7.0+35ubuntu6
php-mysql 1:7.0+35ubuntu6
php-zip 1:7.0+35ubuntu6
php5-common 5.6.17+dfsg-3ubuntu1
php5-curl 5.6.17+dfsg-3ubuntu1
php5-gd 5.6.17+dfsg-3ubuntu1
php5-mysql 5.6.17+dfsg-3ubuntu1
php7.0-cli 7.0.8-0ubuntu0.16.04.3
php7.0-common 7.0.8-0ubuntu0.16.04.3
php7.0-curl 7.0.8-0ubuntu0.16.04.3
php7.0-fpm 7.0.8-0ubuntu0.16.04.3
php7.0-gd 7.0.8-0ubuntu0.16.04.3
php7.0-json 7.0.8-0ubuntu0.16.04.3
php7.0-mbstring 7.0.8-0ubuntu0.16.04.3
php7.0-mysql 7.0.8-0ubuntu0.16.04.3
php7.0-opcache 7.0.8-0ubuntu0.16.04.3
php7.0-readline 7.0.8-0ubuntu0.16.04.3
php7.0-xml 7.0.8-0ubuntu0.16.04.3
php7.0-zip 7.0.8-0ubuntu0.16.04.3
One user also noted that this was a new problem on NC 10.0.1 and reverting back to 10.0.0 solved the issue: https://help.nextcloud.com/t/nextcloud-in-browser-errors-with-spaces-on-filenames/4190/2
Can you check if reverting https://github.com/nextcloud/server/commit/d50e7ee36c5607da848702ca36f7b34505c1622e helps?
So if you add the red lines back to your file.
For me, 10.0.0 has the didn't work either.
I tried on a separate machine using version:
$OC_Version = array(9,1,0,16);
$OC_VersionString = '10.0';
$OC_Edition = '';
$OC_Channel = 'stable';
$OC_VersionCanBeUpgradedFrom = array(9,0);
$OC_Build = '2016-08-25T04:01:11+00:00 678fce3c18c6fbed60076764ae98171eae617c05';
I've tried reverting these, but the problem remains:
lib/private/AppFramework/Http/Request.php
tests/lib/AppFramework/Http/RequestTest.php
@LukasReschke any idea about this exception? Requested uri
(\/cloud\/remote.php\/webdav\/New%20folder) is out of base uri
Please provide all information as requested in the issue template. This includes also the config file etc.
Apologies I've missed an important point in my report. I've installed under a subfolder of the document root.
https://example.com/coud/
Not
https://example.com/
@nickvergessen I've done a little investigation which showed this exception is thrown when a requested URI is outside of the files managed my nextcloud. For some reason, when the filename has spaces in, it finds an incorrect base URL / base URI.
In my case /cloud/remote.php/webdav/New%20folder is the correct location.
And /remote.php/webdav/ is not the correct base (it misses /cloud)
(\/cloud\/remote.php\/webdav\/New%20folder) is out of base uri
(\/remote.php\/webdav\/)
@LukasReschke Apologies for missing something obvious. Where do I find the template? I'll need a little time to sanitize the config before I can post them on the web.
I just found a workaround to the problem. Spaces in filenames work when using a file handler to set up the connection to the php fpm backend from Apache rather than a ProxyPass directive.
The commented statement was the non functioning directive to connect the backend. However that worked fine before performing the upgrade from Owncloud.
<FilesMatch \.php$>
SetHandler "proxy:fcgi://localhost:9001/"
</FilesMatch>
# ProxyPassMatch "^/(.*\.php(/.*)?)$" "fcgi://localhost:9001/opt/owncloud/current"
See https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html#apache-configuration-label for the apache configuration and https://docs.nextcloud.com/server/12/admin_manual/installation/nginx.html for the Nginx configuration
I just had a similar issue with Nextcloud 13.0.5 (Apache 2.4.29, php-fpm 7.0.28 via a Unix socket): It was impossible to create files with spaces in their name or path. This led to the following errors
Exception: The requested uri(/remote.php/dav/files/some%20path/file) cannot be processed by the script '/remote.php/dav/files/some%20path/file)
#1 /nextcloud/lib/private/AppFramework/Http/Request.php - line 755: OC\AppFramework\Http\Request->getRawPathInfo()
#2 /nextcloud/remote.php - line 126: OC\AppFramework\Http\Request->getPathInfo()
#3 {main}
and
Sabre\DAV\Exception: The REQUEST_URI (/remote.php/webdav/some%20path/file) did not end with the contents of PATH_INFO (/webdav/music/some%20path/file). This server might be misconfigured.
#1 /nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 349: Sabre\DAV\Server->guessBaseUri()
#2 /nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 253: Sabre\DAV\Server->getBaseUri()
#3 /nextcloud/remote.php - line 72: Sabre\DAV\Server->exec()
#4 /nextcloud/remote.php - line 167: handleException(Object(Exception))
#5 {main}
I'm recording the fix here for later reference: As above, using FileMatch rather than a ProxyPassMatch fixed the issue, with a twist for the use of a Unix socket:
<VirtualHost *:443>
ServerName cloud.example.net
DocumentRoot /nextcloud/
# Forward authorisation headers to Nextcloud, for app passwords and bearer tokens to be handled by the app
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# XXX: Fails for paths with spaces
#ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php-fpm.sock|fcgi://localhost/nextcloud/
<FilesMatch ".*\.php$">
# Note that the base path is not provided to the fcgi part of the handler, unlike ProxyPassMatch
SetHandler "proxy:unix:/run/php-fpm.sock|fcgi://localhost/"
</FilesMatch>
SSLEngine on
SSLCertificateChainFile /etc/letsencrypt/live/www.example.net/fullchain.pem
SSLCertificAteFile /etc/letsencrypt/live/www.example.net/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.net/privkey.pem
</VirtualHost>
Most helpful comment
I just found a workaround to the problem. Spaces in filenames work when using a file handler to set up the connection to the php fpm backend from Apache rather than a ProxyPass directive.
The commented statement was the non functioning directive to connect the backend. However that worked fine before performing the upgrade from Owncloud.