Bladeren bron

Restrict proppatch to the proper nodes

Need to fetch the node earlier because cancelling from within the
handler is not possible. Well, it is but it prevents other node types
using the same property names to run because the failure marks the
property with status 403.
tags/v12.0.0beta1
Vincent Petry 7 jaren geleden
bovenliggende
commit
1c40a05204
No account linked to committer's email address

+ 7
- 10
apps/dav/lib/Connector/Sabre/FilesPlugin.php Bestand weergeven

@@ -386,25 +386,22 @@ class FilesPlugin extends ServerPlugin {
* @return void
*/
public function handleUpdateProperties($path, PropPatch $propPatch) {
$propPatch->handle(self::LASTMODIFIED_PROPERTYNAME, function($time) use ($path) {
$node = $this->tree->getNodeForPath($path);
if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) {
return;
}

$propPatch->handle(self::LASTMODIFIED_PROPERTYNAME, function($time) use ($node) {
if (empty($time)) {
return false;
}
$node = $this->tree->getNodeForPath($path);
if (is_null($node)) {
return 404;
}
$node->touch($time);
return true;
});
$propPatch->handle(self::GETETAG_PROPERTYNAME, function($etag) use ($path) {
$propPatch->handle(self::GETETAG_PROPERTYNAME, function($etag) use ($node) {
if (empty($etag)) {
return false;
}
$node = $this->tree->getNodeForPath($path);
if (is_null($node)) {
return 404;
}
if ($node->setEtag($etag) !== -1) {
return true;
}

+ 7
- 10
apps/dav/lib/Connector/Sabre/TagsPlugin.php Bestand weergeven

@@ -267,20 +267,17 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin
* @return void
*/
public function handleUpdateProperties($path, PropPatch $propPatch) {
$propPatch->handle(self::TAGS_PROPERTYNAME, function($tagList) use ($path) {
$node = $this->tree->getNodeForPath($path);
if (is_null($node)) {
return 404;
}
$node = $this->tree->getNodeForPath($path);
if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) {
return;
}

$propPatch->handle(self::TAGS_PROPERTYNAME, function($tagList) use ($node) {
$this->updateTags($node->getId(), $tagList->getTags());
return true;
});

$propPatch->handle(self::FAVORITE_PROPERTYNAME, function($favState) use ($path) {
$node = $this->tree->getNodeForPath($path);
if (is_null($node)) {
return 404;
}
$propPatch->handle(self::FAVORITE_PROPERTYNAME, function($favState) use ($node) {
if ((int)$favState === 1 || $favState === 'true') {
$this->getTagger()->tagAs($node->getId(), self::TAG_FAVORITE);
} else {

+ 6
- 6
apps/dav/lib/SystemTag/SystemTagPlugin.php Bestand weergeven

@@ -268,17 +268,17 @@ class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
* @return void
*/
public function handleUpdateProperties($path, PropPatch $propPatch) {
$node = $this->server->tree->getNodeForPath($path);
if (!($node instanceof SystemTagNode)) {
return;
}

$propPatch->handle([
self::DISPLAYNAME_PROPERTYNAME,
self::USERVISIBLE_PROPERTYNAME,
self::USERASSIGNABLE_PROPERTYNAME,
self::GROUPS_PROPERTYNAME,
], function($props) use ($path) {
$node = $this->server->tree->getNodeForPath($path);
if (!($node instanceof SystemTagNode)) {
return;
}

], function($props) use ($node) {
$tag = $node->getSystemTag();
$name = $tag->getName();
$userVisible = $tag->isUserVisible();

Laden…
Annuleren
Opslaan