Merge pull request #4500 from nextcloud/downstream-27118
Restrict proppatch to the proper nodes
This commit is contained in:
commit
527369be9c
|
@ -386,25 +386,22 @@ class FilesPlugin extends ServerPlugin {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function handleUpdateProperties($path, PropPatch $propPatch) {
|
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)) {
|
if (empty($time)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$node = $this->tree->getNodeForPath($path);
|
|
||||||
if (is_null($node)) {
|
|
||||||
return 404;
|
|
||||||
}
|
|
||||||
$node->touch($time);
|
$node->touch($time);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
$propPatch->handle(self::GETETAG_PROPERTYNAME, function($etag) use ($path) {
|
$propPatch->handle(self::GETETAG_PROPERTYNAME, function($etag) use ($node) {
|
||||||
if (empty($etag)) {
|
if (empty($etag)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$node = $this->tree->getNodeForPath($path);
|
|
||||||
if (is_null($node)) {
|
|
||||||
return 404;
|
|
||||||
}
|
|
||||||
if ($node->setEtag($etag) !== -1) {
|
if ($node->setEtag($etag) !== -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,20 +267,17 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function handleUpdateProperties($path, PropPatch $propPatch) {
|
public function handleUpdateProperties($path, PropPatch $propPatch) {
|
||||||
$propPatch->handle(self::TAGS_PROPERTYNAME, function($tagList) use ($path) {
|
$node = $this->tree->getNodeForPath($path);
|
||||||
$node = $this->tree->getNodeForPath($path);
|
if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) {
|
||||||
if (is_null($node)) {
|
return;
|
||||||
return 404;
|
}
|
||||||
}
|
|
||||||
|
$propPatch->handle(self::TAGS_PROPERTYNAME, function($tagList) use ($node) {
|
||||||
$this->updateTags($node->getId(), $tagList->getTags());
|
$this->updateTags($node->getId(), $tagList->getTags());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
$propPatch->handle(self::FAVORITE_PROPERTYNAME, function($favState) use ($path) {
|
$propPatch->handle(self::FAVORITE_PROPERTYNAME, function($favState) use ($node) {
|
||||||
$node = $this->tree->getNodeForPath($path);
|
|
||||||
if (is_null($node)) {
|
|
||||||
return 404;
|
|
||||||
}
|
|
||||||
if ((int)$favState === 1 || $favState === 'true') {
|
if ((int)$favState === 1 || $favState === 'true') {
|
||||||
$this->getTagger()->tagAs($node->getId(), self::TAG_FAVORITE);
|
$this->getTagger()->tagAs($node->getId(), self::TAG_FAVORITE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -268,17 +268,17 @@ class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function handleUpdateProperties($path, PropPatch $propPatch) {
|
public function handleUpdateProperties($path, PropPatch $propPatch) {
|
||||||
|
$node = $this->server->tree->getNodeForPath($path);
|
||||||
|
if (!($node instanceof SystemTagNode)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$propPatch->handle([
|
$propPatch->handle([
|
||||||
self::DISPLAYNAME_PROPERTYNAME,
|
self::DISPLAYNAME_PROPERTYNAME,
|
||||||
self::USERVISIBLE_PROPERTYNAME,
|
self::USERVISIBLE_PROPERTYNAME,
|
||||||
self::USERASSIGNABLE_PROPERTYNAME,
|
self::USERASSIGNABLE_PROPERTYNAME,
|
||||||
self::GROUPS_PROPERTYNAME,
|
self::GROUPS_PROPERTYNAME,
|
||||||
], function($props) use ($path) {
|
], function($props) use ($node) {
|
||||||
$node = $this->server->tree->getNodeForPath($path);
|
|
||||||
if (!($node instanceof SystemTagNode)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tag = $node->getSystemTag();
|
$tag = $node->getSystemTag();
|
||||||
$name = $tag->getName();
|
$name = $tag->getName();
|
||||||
$userVisible = $tag->isUserVisible();
|
$userVisible = $tag->isUserVisible();
|
||||||
|
|
Loading…
Reference in New Issue