Skip to content

Commit

Permalink
Merge pull request #28757 from nextcloud/backport/28726/stable19
Browse files Browse the repository at this point in the history
[stable19] Check if SVG path is valid
  • Loading branch information
LukasReschke committed Sep 8, 2021
2 parents 7f88016 + 4efd8fa commit 37481f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions core/Controller/SvgController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

namespace OC\Core\Controller;

use OC\Files\Filesystem;
use OC\Template\IconsCacher;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
Expand Down Expand Up @@ -117,6 +118,10 @@ public function getSvgFromApp(string $app, string $fileName, string $color = 'ff
* @return DataDisplayResponse|NotFoundResponse
*/
private function getSvg(string $path, string $color, string $fileName) {
if (!Filesystem::isValidPath($path)) {
return new NotFoundResponse();
}

if (!file_exists($path)) {
return new NotFoundResponse();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Controller/SvgControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function testGetSvgFromApp(string $appName, string $name, string $color,
$this->appManager->expects($this->once())
->method('getAppPath')
->with($appName)
->willReturn(__DIR__ . '/../../../apps/' . $appName);
->willReturn(realpath(__DIR__ . '/../../../apps/') . '/' . $appName);

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

Expand Down

0 comments on commit 37481f4

Please sign in to comment.