Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle Depth header for COPY as this is required by RFC #1495

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Oct 25, 2023

Currently Sabre\DAV does not support the Depth header on COPY and MOVE.
But the RFC4918 requires servers to do so, the header is not required but:

  • If the header is missing 'infinity' shall be assumed -> This is how we handle every request currently
  • For MOVE the header, if available, must be 'infinity' -> We just have to check the header and throw bad request otherwise
  • For COPY the header may 'infinity' or a positive integer including 0
    • The depths defines how many levels of children shall be copied
    • If the depth is zero only the collection and its properties are copied, but not any children

So especially the COPY method is currently broken, we noticed this when using the WebDAV litmus test bench (version 0.14) which checks for shallow copies (meaning copy a collection with depth 0).

This PR fixes all of this points, while trying to keep backwards compatible. Of cause any using application that implements ICopyTarget::copyInto is still broken and need to adapt to the depth change (it continues to work as before, but the bug fix does not propagate).

Reference from the RFC:

  • The requirement on the server support of COPY Depth 'infinity' and '0': rfc4918#section-9.8.3
  • For MOVE only Depth: infinity is allowed: rfc4918#section-9.9.2

Only `Depth: infinity` is allowed, ref: rfc4918#section-9.9.2

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1. According to the RFC[1] servers **must** support `Depth` 'infinity' and 0.
2. And COPY method on a collection without a Depth header MUST act as if
a Depth header with value "infinity" was included.

[1] rfc4918#section-9.8.3

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>

// Depth of inifinty is valid for MOVE and COPY. If it is not set the RFC requires to act like it was 'infinity'.
$depth = strtolower($request->getHeader('Depth') ?? 'infinity');
if ($depth !== 'infinity' && is_numeric($depth)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In core plugin above it is stated that only infinity is allowed. Adding this logic here can reduce the necessary code changes a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DeepDiver1975 yes thats for MOVE, but for COPY we need to support also numeric values.

@susnux
Copy link
Contributor Author

susnux commented Apr 4, 2024

ping again, also cc @phil-davis

Would be great to get this fixed so sabre passes the litmus test v15 ( https://github.com/notroj/litmus previously http://www.webdav.org/neon/litmus/ )

@phil-davis phil-davis self-assigned this Apr 18, 2024
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.

None yet

3 participants