diff --git a/src/core/controllers/InstallerController.php b/src/core/controllers/InstallerController.php index 085e450a55ff6daecd0b40b7dcb84c89538cf71f..6855973b8a08d2fdde49590b27d5a9fe406aace8 100644 --- a/src/core/controllers/InstallerController.php +++ b/src/core/controllers/InstallerController.php @@ -105,7 +105,7 @@ class InstallerController return $response->withStatus(400)->withJson(['errors' => 'QueryParams name is empty or not a string']); } elseif (!Validator::length(1, 50)->validate($queryParams['name'])) { return $response->withStatus(400)->withJson(['errors' => 'QueryParams name length is not valid']); - } elseif (strpbrk($queryParams['name'], '"; ') !== false) { + } elseif (strpbrk($queryParams['name'], '"; \\') !== false) { return $response->withStatus(400)->withJson(['errors' => 'QueryParams name is not valid']); } @@ -288,7 +288,7 @@ class InstallerController return $response->withStatus(400)->withJson(['errors' => 'Body name is empty or not a string']); } elseif (!Validator::length(1, 50)->validate($body['name'])) { return $response->withStatus(400)->withJson(['errors' => 'Body name length is not valid']); - } elseif (strpbrk($body['name'], '"; ') !== false) { + } elseif (strpbrk($body['name'], '"; \\') !== false) { return $response->withStatus(400)->withJson(['errors' => 'Body name is not valid']); } elseif (!Validator::stringType()->notEmpty()->validate($body['customId'])) { return $response->withStatus(400)->withJson(['errors' => 'Body customId is empty or not a string']); @@ -579,12 +579,14 @@ class InstallerController $explodedUrl = explode('/', rtrim($url, '/')); $lastPart = $explodedUrl[count($explodedUrl) - 1]; - $jsonFile = file_get_contents('custom/custom.json'); - if (!empty($jsonFile)) { - $jsonFile = json_decode($jsonFile, true); - foreach ($jsonFile as $value) { - if (!empty($value['path']) && $value['path'] == $lastPart) { - $url = str_replace("/{$lastPart}", '', $url); + if (is_file('custom/custom.json')) { + $jsonFile = file_get_contents('custom/custom.json'); + if (!empty($jsonFile)) { + $jsonFile = json_decode($jsonFile, true); + foreach ($jsonFile as $value) { + if (!empty($value['path']) && $value['path'] == $lastPart) { + $url = str_replace("/{$lastPart}", '', $url); + } } } } diff --git a/test/unitTests/app/entity/EntityControllerTest.php b/test/unitTests/app/entity/EntityControllerTest.php index ada11b65d36971c9b4cd3fada1ef95623a89d042..e5558ff7ab7fdbb3ad7ec849217e40ef6e5173cd 100755 --- a/test/unitTests/app/entity/EntityControllerTest.php +++ b/test/unitTests/app/entity/EntityControllerTest.php @@ -505,6 +505,8 @@ class EntityControllerTest extends TestCase $response = $entityController->create($fullRequest, new \Slim\Http\Response()); $this->assertSame(200, $response->getStatusCode()); + \User\models\UserEntityModel::deleteUserEntity(['id' => $GLOBALS['id'], 'entityId' => 'R2-D2']); + $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'PUT']); $request = \Slim\Http\Request::createFromEnvironment($environment); $response = $entityController->reassignEntity($request, new \Slim\Http\Response(), ['id' => 'R2-D2', 'newEntityId' => 'TEST-ENTITY123']);