[Bug]: Impossible to rename or delete files with invalid characters in their names
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
With the latest stable29, after setting some forbidden characters for file names, the existing files/directories that have those characters in their names can't be renamed at all anymore.
Sabre complains that there is at least one invalid char in the name even if there is no invalid char in the target name but only in the current name.
Steps to reproduce
- Create a file named
a%b.txt - Add
'forbidden_chars' => ['%'],to config.php - Try to rename the file to
ab.txt - The MOVE request fails.
MOVE/remote.php/dav/files/admin/specialchars/a%25b.md
with theDestinationheader being/remote.php/dav/files/admin/specialchars/ab.md
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Internal Server Error</s:exception>
<s:message>
The server was unable to complete your request. If this happens again, please send the technical details below to the server administrator. More details can be found in the server log. </s:message>
<s:technical-details>
<s:remote-address>192.168.21.3</s:remote-address>
<s:request-id>tEi9t7j2C4ZKeEsBblSc</s:request-id>
<s:type>OCA\DAV\Connector\Sabre\Exception\InvalidPath</s:type>
<s:code>0</s:code>
<s:message>File name contains at least one invalid character</s:message>
<s:file>/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php</s:file>
<s:line>219</s:line>
<s:stacktrace>
#0 /var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php(95): OCA\DAV\Connector\Sabre\Directory->getChild('a%b.md')
#1 /var/www/html/apps/dav/lib/DAV/ViewOnlyPlugin.php(76): Sabre\DAV\Tree->getNodeForPath('files/admin/spe...')
#2 /var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php(89): OCA\DAV\DAV\ViewOnlyPlugin->checkViewOnly(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
#3 /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php(472): Sabre\DAV\Server->emit('method:MOVE', Array)
#4 /var/www/html/apps/dav/lib/Connector/Sabre/Server.php(61): Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
#5 /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php(321): OCA\DAV\Connector\Sabre\Server->start()
#6 /var/www/html/apps/dav/lib/Server.php(393): Sabre\DAV\Server->exec()
#7 /var/www/html/apps/dav/appinfo/v2/remote.php(35): OCA\DAV\Server->exec()
#8 /var/www/html/remote.php(172): require_once('/var/www/html/a...')
#9 {main} </s:stacktrace>
</s:technical-details>
</d:error>
Expected behavior
In NC >= 30, those files can be renamed to a valid name even if the current name is invalid.
Nextcloud Server version
29
Operating system
None
PHP engine version
None
Web server
None
Database engine version
None
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in apps/dav/lib/Connector/Sabre/Directory.php around line 219 and trace the MOVE request shown in the stack trace. Reproduce the configured forbidden character case, then verify that an existing file with an invalid current name can be renamed to a valid target name without triggering InvalidPath.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100