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

Can get a container with a trailing slash, which then causes issues #645

Closed
PatrickRose opened this issue Nov 10, 2015 · 1 comment
Closed

Comments

@PatrickRose
Copy link

I've been using the flysystem-rackspace plugin to handle our file access abstraction, and just came across this (I'll try and send a PR tonight to fix though I'm not sure what the correct resolution should be)

$oOpenstack = new \OpenCloud\OpenStack(
    // Config
);

$oStore = $oOpenstack->objectStoreService($sServiceName, 'RegionOne');

// Allows trailing slash here
$container = $oStore->getContainer('test_container/');
$container->uploadObject('object-name', 'test');
$dataObject = $container->dataObject('object-name');
// flysystem-rackspace does this in the copy
$destination = '/'.$container->getName().'/newname/';
$response = $dataObject->copy($destination);

foreach($container->objectList() as $object)
{
    // The object name is now "/newname"
    // But this delete hits /test_container/newname instead of /test_container//newname
    $object->delete();
}

I imagine this breaks other things as well, but that's the first one I found.

@PatrickRose
Copy link
Author

Actually it looks like there's further oddities.

If my object name begins with a slash (maybe I'm crazy, or I've made a mistake when specifying the object name) I can't delete it even if the container name doesn't have a trailing slash

$oOpenstack = new \OpenCloud\OpenStack(
    // Config
);

$oStore = $oOpenstack->objectStoreService($sServiceName, 'RegionOne');

// Allows trailing slash here
$container = $oStore->getContainer('test_container/');
$container->uploadObject('object-name', 'test');
$dataObject = $container->dataObject('object-name');
// flysystem-rackspace does this in the copy
$destination = '/'.$container->getName().'//newname';
$response = $dataObject->copy($destination);

foreach($container->objectList() as $object)
{
    // The object name is now "/newname"
    // But this delete hits /test_container/newname instead of /test_container//newname
    $object->delete();
}

I think getUrl needs to urlencode the object name instead (otherwise the url won't include that initial slash).

Arguably the user shouldn't do this, but I managed it...

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

No branches or pull requests

1 participant