mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
Merge pull request #28726 from nextcloud/check-if-path-is-valid
Check if SVG path is valid
This commit is contained in:
commit
d4d1f5dfce
2 changed files with 6 additions and 1 deletions
|
|
@ -31,6 +31,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;
|
||||
|
|
@ -117,6 +118,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