Skip to content

Commit d4d1f5d

Browse files
authored
Merge pull request #28726 from nextcloud/check-if-path-is-valid
Check if SVG path is valid
2 parents 3ead598 + 19ad636 commit d4d1f5d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

core/Controller/SvgController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*/
3232
namespace OC\Core\Controller;
3333

34+
use OC\Files\Filesystem;
3435
use OC\Template\IconsCacher;
3536
use OCP\App\AppPathNotFoundException;
3637
use OCP\App\IAppManager;
@@ -117,6 +118,10 @@ public function getSvgFromApp(string $app, string $fileName, string $color = 'ff
117118
* @return DataDisplayResponse|NotFoundResponse
118119
*/
119120
private function getSvg(string $path, string $color, string $fileName) {
121+
if (!Filesystem::isValidPath($path)) {
122+
return new NotFoundResponse();
123+
}
124+
120125
if (!file_exists($path)) {
121126
return new NotFoundResponse();
122127
}

tests/Core/Controller/SvgControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function testGetSvgFromApp(string $appName, string $name, string $color,
183183
$this->appManager->expects($this->once())
184184
->method('getAppPath')
185185
->with($appName)
186-
->willReturn(__DIR__ . '/../../../apps/' . $appName);
186+
->willReturn(realpath(__DIR__ . '/../../../apps/') . '/' . $appName);
187187

188188
$response = $this->svgController->getSvgFromApp($appName, $name, $color);
189189

0 commit comments

Comments
 (0)