Skip to content

WebDAV: Trailing slash for DELETE and MOVE on dirs#1535

Open
njam wants to merge 2 commits intozhanghai:masterfrom
njam:webdav-slash
Open

WebDAV: Trailing slash for DELETE and MOVE on dirs#1535
njam wants to merge 2 commits intozhanghai:masterfrom
njam:webdav-slash

Conversation

@njam
Copy link
Copy Markdown

@njam njam commented Mar 13, 2026

According to WebDAV RFC when issuing a MOVE or DELETE on a folder (instead of a file), the path should have a trailing slash.

Fixes #1475

@zhanghai do you accept contributions?

I've tested it against the Nginx webdav server.

The only downside with this change I can see is that it adds one more PROPFIND when deleting files or folders. It guess it could be avoided, but would require quite some code changes, to pass along the information whether the path to be deleted is a file or a folder.

According to WebDAV RFC when issuing a MOVE or DELETE on a folder (instead of a file), the path should have a trailing slash.

For example the nginx webdav server requires this for it to work.
@zhanghai
Copy link
Copy Markdown
Owner

zhanghai commented Mar 13, 2026

I indeed don't like a new PROPFIND, in addition to more code logic for this... And since it's a SHOULD (i.e. merely RECOMMENDED and can be ignored, according to RFC 2119) instead of MUST, I feel nginx is supposed to handle both cases to be compliant instead of every client being forced to take SHOULD as MUST and have more complicated logic or send extra requests.

@njam
Copy link
Copy Markdown
Author

njam commented Mar 14, 2026

Yeah it's better to avoid an additional PROPFIND. There are actually already 2 PROPFIND before deleting a file, and 4 before deleting a directory. It is better not to add another one.

I agree, Nginx should handle this differently. But it's unlikely that they will change it. Without changing MaterialFiles' implementation it won't work together with Nginx.

As you say it's "recommended" to add the trailing slash, so it's definitely better to add it than not to add it.

I've pushed a commit that changes fun Path.delete() to fun Path.delete(isDirectory: Boolean?), and passes along isDirectory from the callers, to avoid an additional PROPFIND in most cases (except for ForeignCopyMove). I think it's quite readable.

wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebDav DELETE request for directories is missing trailing slash

2 participants