mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 08:16:43 -04:00
Merge pull request #28735 from nextcloud/backport/28726/stable21
[stable21] Check if SVG path is valid
This commit is contained in:
commit
7dece11af0
2 changed files with 6 additions and 1 deletions
|
|
@ -32,6 +32,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace OC\Core\Controller;
|
||||
|
||||
use OC\Files\Filesystem;
|
||||
use OC\Template\IconsCacher;
|
||||
use OCP\App\AppPathNotFoundException;
|
||||
use OCP\App\IAppManager;
|
||||
|
|
@ -118,6 +119,10 @@ class SvgController extends Controller {
|
|||
* @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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ class SvgControllerTest extends TestCase {
|
|||
$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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue