Skip to content

Commit 84fcc3f

Browse files
committed
bug #2600 [Autocomplete] Rethrow BadRequestHttpException in case of malformed extra_options (norkunas)
This PR was merged into the 2.x branch. Discussion ---------- [Autocomplete] Rethrow `BadRequestHttpException` in case of malformed `extra_options` | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Issues | N/A | License | MIT Currently it's enough just to manually edit extra_options in URL to a random string and then get a 500 error while polluting logs. I think it's better to swallow it and properly exit with 400 status. Commits ------- e59554a [Autocomplete] Rethrow `BadRequestHttpException` in case of malformed `extra_options`
2 parents 65458d6 + e59554a commit 84fcc3f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Autocomplete/src/Controller/EntityAutocompleteController.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ private function getExtraOptions(Request $request): array
7676
return [];
7777
}
7878

79-
$extraOptions = $this->getDecodedExtraOptions($request->query->getString(self::EXTRA_OPTIONS));
79+
try {
80+
$extraOptions = $this->getDecodedExtraOptions($request->query->getString(self::EXTRA_OPTIONS));
81+
} catch (\JsonException $e) {
82+
throw new BadRequestHttpException('The extra options cannot be parsed.', $e);
83+
}
8084

8185
if (!\array_key_exists(AutocompleteChoiceTypeExtension::CHECKSUM_KEY, $extraOptions)) {
8286
throw new BadRequestHttpException('The extra options are missing the checksum.');

0 commit comments

Comments
 (0)