Skip to content

Commit

Permalink
Harden JsonMapper defaults in general
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Feb 23, 2024
1 parent 6872661 commit db665fe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ public static function loadSchemaFromString(string $raw, int $schemaId) : BlockS
}

$jsonMapper = new \JsonMapper();
$jsonMapper->bExceptionOnMissingData = true;
$jsonMapper->bExceptionOnUndefinedProperty = true;
$jsonMapper->bStrictObjectTypeChecking = true;
try{
$model = $jsonMapper->map($json, new BlockStateUpgradeSchemaModel());
}catch(\JsonMapper_Exception $e){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public static function loadSchemaFromString(string $raw, int $schemaId) : ItemId
}

$jsonMapper = new \JsonMapper();
$jsonMapper->bExceptionOnMissingData = true;
$jsonMapper->bExceptionOnUndefinedProperty = true;
$jsonMapper->bStrictObjectTypeChecking = true;
try{
$model = $jsonMapper->map($json, new ItemIdMetaUpgradeSchemaModel());
}catch(\JsonMapper_Exception $e){
Expand Down
1 change: 1 addition & 0 deletions src/resourcepacks/ZippedResourcePack.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function __construct(string $zipPath){

$mapper = new \JsonMapper();
$mapper->bExceptionOnMissingData = true;
$mapper->bStrictObjectTypeChecking = true;

try{
/** @var Manifest $manifest */
Expand Down
1 change: 1 addition & 0 deletions src/updater/UpdateCheckTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function onRun() : void{
}else{
$mapper = new \JsonMapper();
$mapper->bExceptionOnMissingData = true;
$mapper->bStrictObjectTypeChecking = true;
$mapper->bEnforceMapType = false;
try{
/** @var UpdateInfo $responseObj */
Expand Down

0 comments on commit db665fe

Please sign in to comment.