public function testEscapeshellarg() { $this->assertEquals(\BeeHub::escapeshellarg('some text \' with quotes in it'), "'" . 'some text \'\\\'\' with quotes in it' . "'", 'BeeHub::best_xml_type() should return correct value'); }
public function method_COPY($path) { $this->assert(BeeHub::PRIV_READ_CONTENT); $this->assert(DAVACL::PRIV_READ_ACL); $destinationResource = DAV::$REGISTRY->resource($path); $parent = DAV::$REGISTRY->resource(dirname($path)); if (!$parent) { throw new DAV_Status(DAV::HTTP_CONFLICT, 'Unable to COPY to unexisting collection'); } if (!$parent instanceof BeeHub_Directory) { throw new DAV_Status(DAV::HTTP_FORBIDDEN); } if ($destinationResource instanceof DAVACL_Resource) { $destinationResource->assert(DAVACL::PRIV_WRITE_CONTENT); $destinationResource->assert(DAVACL::PRIV_WRITE_ACL); $parent->method_DELETE(basename($path)); } else { $parent->assert(DAVACL::PRIV_WRITE_CONTENT); } // Determine the sponsor $user = BeeHub::getAuth()->current_user(); $user_sponsors = $user->user_prop_sponsor_membership(); if (count($user_sponsors) === 0) { // If the user doesn't have any sponsors, he/she can't create files and directories throw DAV::forbidden(); } $localPath = BeeHub::localPath($path); exec('cp ' . BeeHub::escapeshellarg($this->localPath) . ' ' . BeeHub::escapeshellarg($localPath)); // And copy the attributes $new_resource = new BeeHub_File($path); foreach ($this->stored_props as $prop => $value) { if (!in_array($prop, array(DAV::PROP_OWNER, BeeHub::PROP_SPONSOR, DAV::PROP_ACL, DAV::PROP_GETETAG, DAV::PROP_LOCKDISCOVERY))) { $new_resource->user_set($prop, $value); } } $sponsor = $parent->user_prop_sponsor(); // The default is the directory sponsor if (!in_array($sponsor, $user_sponsors)) { //But a user can only create files sponsored by his own sponsors $sponsor = $user->user_prop(BeeHub::PROP_SPONSOR); } // And set the new properties $new_resource->user_set(DAV::PROP_OWNER, $this->user_prop_current_user_principal()); $new_resource->user_set(BeeHub::PROP_SPONSOR, $sponsor); $new_resource->user_set(DAV::PROP_GETETAG, BeeHub::ETag()); $new_resource->storeProperties(); }