Skip to content
Snippets Groups Projects

Issue #3408255: Blocked rerouting of URL for jsonapi

1 file
+ 16
4
Compare changes
  • Side-by-side
  • Inline
@@ -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);
}
}
Loading