Skip to content

Wrong PROPFIND answer with depth infinity requests #28341

Closed

Description

@blancjerome

Hi,

I found a strange behavior with infinity depth propfind requests : under subdirectories, files are reported as directories. This is due to a Collection resource type returned in the propfind response. It occurs only for level 2 subdirectories and above.

This behavior appeared with 10.0.x version of owncloud, but it maybe was there in the 9.1.x as I discovered it after upgrading from a 9.0.x version.

I didn't found any report of this bug, except with nextcloud, but no answer yet (nextcloud/server#5543).
I don't know what's the relationship between owncloud and nextcloud except the fact that they obviously share some code.

Because my client (Documents by Readdle) couldn't sync properly, I took a look at the code and found where the problem is.

In /var/www/html/owncloud/lib/composer/sabre/dav/lib/DAV/Server.php, the "generatePathNodes" method clones "ProFind" objects. But as these objects have been created for the containing directory, they already contain the "Collection" value for the "ResourceType" property. So the workaround is creating a brand new "PropFind" object instead of cloning it.

I hope the correction will be included in the future version of owncloud, I don't think it has an impact on memory footprint, maybe a bit on performance because Propfind objects have to be filled again. But I haven't seen any significant change.

Here is the new code for the method :

 * Small helper to support PROPFIND with DEPTH_INFINITY.
 *
 *
 * @param PropFind $propFind
 * @param array $yieldFirst
 * @return \Iterator
 */
private function generatePathNodes(PropFind $propFind, array $yieldFirst = null) {
    if ($yieldFirst !== null) {
        yield $yieldFirst;
    }
    $newDepth = $propFind->getDepth();
    $path = $propFind->getPath();

    if ($newDepth !== self::DEPTH_INFINITY) {
        $newDepth--;
    }

//FIX in order to create new PropFind objects and not clone them
$propertyNames = $propFind->getRequestedProperties();
$propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS;

    foreach ($this->tree->getChildren($path) as $childNode) {
     //FIX : no cloning, creating new PropFind objects
        //$subPropFind = clone $propFind;
        //$subPropFind->setDepth($newDepth);
        if ($path !== '') {
            $subPath = $path . '/' . $childNode->getName();
        } else {
            $subPath = $childNode->getName();
        }
        //$subPropFind->setPath($subPath);

     //FIX : create a new PropFind object with the right parameters
     $subPropFind = new PropFind($subPath, $propertyNames, $newDepth, $propFindType);

        yield [
            $subPropFind,
            $childNode
        ];

        if (($newDepth === self::DEPTH_INFINITY || $newDepth >= 1) && $childNode instanceof ICollection) {
            foreach ($this->generatePathNodes($subPropFind) as $subItem) {
                yield $subItem;
            }
        }

    }
}

Activity

  1. changed the title [-]Wrong PROPFIND answer with depth infinity[/-] [+]Wrong PROPFIND answer with depth infinity requests[/+] on Jul 8, 2017
  2. added this to the triage milestone on Jul 10, 2017
  3. added
    p2-high
    on Jul 10, 2017
  4. PVince81 commented on Jul 14, 2017

    @PVince81
    Contributor

    From what I see this is Sabre code and needs to be submit upstream, and there is already a PR for that: https://github.com/fruux/sabre-dav/pull/982/

    So once the PR is merged, will need to upgrade the Sabre library to get this.

  5. modified the milestones: 10.1, triage on Jul 14, 2017
  6. blancjerome commented on Jul 14, 2017

    @blancjerome
    Author

    Yes. Nextcloud team submitted the fix to Sabre few days ago. So it will be available soon.

  7. welljsjs commented on Oct 9, 2017

    @welljsjs

    Version 10.0.3.3 is out, still not fixed. Same problem here using Documents by Readdle.

  8. PVince81 commented on Oct 9, 2017

    @PVince81
    Contributor
  9. PVince81 commented on Oct 9, 2017

    @PVince81
    Contributor

    It also worries me to see that there hasn't been any new release of the Sabre lib since 3.3. Last commit is from February (https://github.com/fruux/sabre-dav/tree/3.3). And on master last commit is from May 17th https://github.com/fruux/sabre-dav/tree/master.

    @DeepDiver1975 ^

  10. welljsjs commented on Oct 9, 2017

    @welljsjs

    That is pretty sad. Do you have any idea why they did not accept it?
    @PVince81
    EDIT: May have to do something with the owncloud Desktop client. Running it on my Mac, it does not work after changing the Server.php script as described above.

  11. phil-davis commented on Oct 10, 2017

    @phil-davis
    Contributor

    Hmmmm - I remember reading those a few months ago and then forgot all about it. So, what resources can be put in to maintain those Sabre repos?

  12. 16 remaining items

  13. michaelstingl commented on Mar 13, 2018

    @michaelstingl

    We've got feedback, the patch is running fine in production for 2 months now and they did not get any complain so far.

    @DeepDiver1975 When will the patch be merged?

  14. PVince81 commented on Mar 13, 2018

    @PVince81
    Contributor

    the patch was merged already but Sabre DAV needs a new upstream release first, then we can update our composer.json to use the new version

    @DeepDiver1975 can we move this forward?

  15. PaulAnnekov commented on Apr 22, 2018

    @PaulAnnekov

    @PVince81 as I understand you don't want to depend on commit id, right? This would be a solution.

  16. PVince81 commented on Apr 23, 2018

    @PVince81
    Contributor

    @DeepDiver1975 please make a decision for the timeline for upgrading and releasing Sabre. If no release, should we switch to commit id ?

  17. added
    p3-medium
    and removed
    p2-high
    on Apr 23, 2018
  18. patrickjahns commented on Aug 30, 2018

    @patrickjahns
    Contributor

    Might also be related:
    #32009 (comment)

  19. PVince81 commented on Nov 5, 2018

    @PVince81
    Contributor

    as far as I can see we've updated Sabre on stable10 here #33276 and it contains the mentioned fix from #28341 (comment)

  20. locked as resolved and limited conversation to collaborators on Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type:Bugp3-medium

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions