Propfind error 404 with accent and spaces on local external storage

Hi everyone :wave:

Nextcloud version (eg, 20.0.5): 19.0.3
Operating system and version (eg, Ubuntu 20.04): Debian 9.13
Apache or nginx version (eg, Apache 2.4.25): Nginx 1.10.3
PHP version (eg, 7.4): 7.3

My Nextcloud is running on a proxmox VM, on a local server at home.

The issue you are facing:

The folders I added (via FTP) to an external local storage are available through web interface. However, when I try to navigate to a folder with a name including spaces and accent (such as “2020 Héraklion”), I run into a Propfind 404 error, and get redirected to home page.

Is this the first time you’ve seen this error? : Yes

Steps to replicate it:

  1. Add an external storage of type “local”, linking to an existing directory on the server (such as /home/nextcloud/localshare)
  2. Send files to this folder via FTP, with a file name including spaces and accent letters
  3. In your browser, navigate to the external folder : you can see files and folder of the 1st level
  4. Click to access a folder with special name inside the local storage : you get a 404 error.

The output of your Nextcloud log in Admin > Logging:

{"reqId":"Qk6QD7THMMqSI0fR2e2i","level":0,"time":"2021-02-15T13:28:48+00:00","remoteAddr":"109.8.222.182","user":"jaxom","app":"webdav","method":"PROPFIND","url":"/remote.php/dav/files/jaxom/Multimedia/Picture/2014/Coloc%20Chamb%C3%A9%202","message":{"Exception":"Sabre\\DAV\\Exception\\NotFound","Message":"File with name /Multimedia/Picture/2014/Coloc Chambé 2 could not be located","Code":0,"Trace":[{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":80,"function":"getChild","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["Coloc Chambé 2"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":976,"function":"getNodeForPath","class":"Sabre\\DAV\\Tree","type":"->","args":["files/jaxom/Multimedia/Picture/2014/Coloc Chambé 2"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1678,"function":"getPropertiesIteratorForPath","class":"Sabre\\DAV\\Server","type":"->","args":["files/jaxom/Multimedia/Picture/2014/Coloc Chambé 2",["{DAV:}getlastmodified","{DAV:}getetag","{DAV:}getcontenttype","{DAV:}resourcetype","{http://owncloud.org/ns}fileid","{http://owncloud.org/ns}permissions","{http://owncloud.org/ns}size","{DAV:}getcontentlength","{http://nextcloud.org/ns}has-preview","{http://nextcloud.org/ns}mount-type","{http://nextcloud.org/ns}is-encrypted","{http://open-collaboration-services.org/ns}share-permissions","{http://owncloud.org/ns}tags","{http://owncloud.org/ns}favorite","{http://owncloud.org/ns}comments-unread","{http://owncloud.org/ns}owner-id","{http://owncloud.org/ns}owner-display-name","{http://owncloud.org/ns}share-types"],1]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1661,"function":"writeMultiStatus","class":"Sabre\\DAV\\Server","type":"->","args":[{"elementMap":[],"contextUri":"/remote.php/dav/","namespaceMap":{"DAV:":"d","http://sabredav.org/ns":"s","http://owncloud.org/ns":"oc","http://nextcloud.org/ns":"nc"},"classMap":[],"__class__":"Sabre\\Xml\\Writer"},{"__class__":"Generator"},false]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":363,"function":"generateMultiStatus","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Generator"},false]},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPropFind","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":474,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:PROPFIND",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":251,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":319,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":320,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/remote.php","line":167,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","Line":232,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0","version":"19.0.3.1","id":"602a7a024b1f5"}
{"reqId":"tIa1sfPEWuBSZPbvU8OH","level":0,"time":"2021-02-15T13:56:05+00:00","remoteAddr":"109.8.222.182","user":"jaxom","app":"webdav","method":"PROPFIND","url":"/remote.php/dav/files/jaxom/Multimedia/Picture/2014/Fin%20d'%C3%A9t%C3%A9%202015","message":{"Exception":"Sabre\\DAV\\Exception\\NotFound","Message":"File with name /Multimedia/Picture/2014/Fin d'été 2015 could not be located","Code":0,"Trace":[{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":80,"function":"getChild","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["Fin d'été 2015"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":976,"function":"getNodeForPath","class":"Sabre\\DAV\\Tree","type":"->","args":["files/jaxom/Multimedia/Picture/2014/Fin d'été 2015"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1678,"function":"getPropertiesIteratorForPath","class":"Sabre\\DAV\\Server","type":"->","args":["files/jaxom/Multimedia/Picture/2014/Fin d'été 2015",["{DAV:}getlastmodified","{DAV:}getetag","{DAV:}getcontenttype","{DAV:}resourcetype","{http://owncloud.org/ns}fileid","{http://owncloud.org/ns}permissions","{http://owncloud.org/ns}size","{DAV:}getcontentlength","{http://nextcloud.org/ns}has-preview","{http://nextcloud.org/ns}mount-type","{http://nextcloud.org/ns}is-encrypted","{http://open-collaboration-services.org/ns}share-permissions","{http://owncloud.org/ns}tags","{http://owncloud.org/ns}favorite","{http://owncloud.org/ns}comments-unread","{http://owncloud.org/ns}owner-id","{http://owncloud.org/ns}owner-display-name","{http://owncloud.org/ns}share-types"],1]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1661,"function":"writeMultiStatus","class":"Sabre\\DAV\\Server","type":"->","args":[{"elementMap":[],"contextUri":"/remote.php/dav/","namespaceMap":{"DAV:":"d","http://sabredav.org/ns":"s","http://owncloud.org/ns":"oc","http://nextcloud.org/ns":"nc"},"classMap":[],"__class__":"Sabre\\Xml\\Writer"},{"__class__":"Generator"},false]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":363,"function":"generateMultiStatus","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Generator"},false]},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPropFind","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":474,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:PROPFIND",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":251,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":319,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":320,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/remote.php","line":167,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","Line":232,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0","version":"19.0.3.1","id":"602a7e74bc714"}

The folders are then hidden from the web interface, but they are still in my file system, and get redisplayed after the cronjob runs. It seems to be a trouble of how the filesystem manages the special characters ?

:arrow_right: Any tip would be of help, thanks a lot !! :smile_cat:

I think it has to do with the encoding of my FS and of the files transferred. So maybe not due to NC at all.

I’ll look into it and let you know.

Turns out I copied files over from a MacOS system : the UTF-8 encoding uses a different norm :weary: I learned about it by using the convmv command and looking at the manual :
HFS+ on OS X / Darwin

   Linux and (most?) other Unix-like operating systems use the so called normalization form C (NFC) for its UTF-8
   encoding by default but do not enforce this. HFS+ on the Macintosh OS enforces normalization form D (NFD), where a
   few characters are encoded in a different way. On OS X it's not possible to create NFC UTF-8 filenames because this
   is prevented at filesystem layer.  On HFS+ filenames are internally stored in UTF-16 and when converted back to
   UTF-8 (because the Unix based OS can't deal with UTF-16 directly), NFD is created for whatever reason.  See
   http://developer.apple.com/qa/qa2001/qa1173.html for defails. I think it was a very bad idea and breaks many things
   under OS X which expect a normal POSIX conforming system. Anywhere else convmv is able to convert files from NFC to
   NFD or vice versa which makes interoperability with such systems a lot easier.

So I just had to run convmv -f utf8 -t utf8 -r --nfc on the files to encode them back to the “right” norm. Hope it will be helpful to others here !