Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 72d650c

Browse files
committed
Resolve the path before voting
1 parent c69d56e commit 72d650c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Controller/ResourceController.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function getResourceAction($repositoryName, $path)
6767
try {
6868
$repository = $this->registry->get($repositoryName);
6969

70-
$this->guardAccess('read', $repositoryName, $repository->resolvePath($path));
70+
$fullPath = method_exists($repository, 'resolvePath') ? $repository->resolvePath($path) : $path;
71+
$this->guardAccess('read', $repositoryName, $fullPath);
7172

7273
$resource = $repository->get($path);
7374

@@ -102,11 +103,12 @@ public function getResourceAction($repositoryName, $path)
102103
*/
103104
public function patchResourceAction($repositoryName, $path, Request $request)
104105
{
105-
$this->guardAccess('write', $repositoryName, $path);
106-
106+
$path = '/'.ltrim($path, '/');
107107
$repository = $this->registry->get($repositoryName);
108108

109-
$path = '/'.ltrim($path, '/');
109+
$fullPath = method_exists($repository, 'resolvePath') ? $repository->resolvePath($path) : $path;
110+
$this->guardAccess('write', $repositoryName, $fullPath);
111+
110112

111113
$requestContent = json_decode($request->getContent(), true);
112114
if (!$requestContent) {
@@ -142,11 +144,11 @@ public function patchResourceAction($repositoryName, $path, Request $request)
142144
*/
143145
public function deleteResourceAction($repositoryName, $path)
144146
{
145-
$this->guardAccess('write', $repositoryName, $path);
146-
147+
$path = '/'.ltrim($path, '/');
147148
$repository = $this->registry->get($repositoryName);
148149

149-
$path = '/'.ltrim($path, '/');
150+
$fullPath = method_exists($repository, 'resolvePath') ? $repository->resolvePath($path) : $path;
151+
$this->guardAccess('write', $repositoryName, $fullPath);
150152

151153
$repository->remove($path);
152154

0 commit comments

Comments
 (0)