Skip to content
Snippets Groups Projects
Commit d3d996e7 authored by Jürgen Haas's avatar Jürgen Haas
Browse files

Issue #3408255 by jurgenhaas, saurabh-2k17: Blocked rerouting of URL for jsonapi

parent b32e2837
No related branches found
No related tags found
1 merge request!3Issue #3408255: Blocked rerouting of URL for jsonapi
Pipeline #69435 passed
......@@ -107,8 +107,6 @@ class ResponseSubscriber implements EventSubscriberInterface {
*
* @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event
* The filter event.
*
* @throws \JsonException
*/
public function onResponse(ResponseEvent $event): void {
if ($this->nodeStorage === NULL || !$this->routeMatch->getRouteObject()) {
......@@ -117,7 +115,15 @@ class ResponseSubscriber implements EventSubscriberInterface {
if ($this->routeMatch->getRouteName() === 'jsonapi.resource_list' || Routes::isJsonApiRequest($this->routeMatch->getRouteObject()->getDefaults())) {
$response = $event->getResponse();
$content = $response->getContent();
$jsonapi_response = json_decode($content, TRUE, 512, JSON_THROW_ON_ERROR);
if (!$content) {
return;
}
try {
$jsonapi_response = json_decode($content, TRUE, 512, JSON_THROW_ON_ERROR);
}
catch (\JsonException) {
return;
}
if (!is_array($jsonapi_response)) {
return;
}
......@@ -131,7 +137,13 @@ class ResponseSubscriber implements EventSubscriberInterface {
$this->findBookDefinition($jsonapi_response['data'][$key]['attributes']);
}
}
$response->setContent(json_encode($jsonapi_response, JSON_THROW_ON_ERROR));
try {
$content = json_encode($jsonapi_response, JSON_THROW_ON_ERROR);
}
catch (\JsonException) {
return;
}
$response->setContent($content);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment