Skip to content

Commit

Permalink
Prefer static call and precise exception
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and tobias-93 committed Jul 4, 2023
1 parent 171df43 commit 9493cbd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Controller/Controller.php
Expand Up @@ -20,7 +20,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

/**
* Controller class.
Expand Down Expand Up @@ -82,9 +82,8 @@ public function indexAction(Request $request, $_format): Response
$content = $this->serializer->serialize($routesResponse, 'json');

if (null !== $callback = $request->query->get('callback')) {
$validator = new \JsonpCallbackValidator();
if (!$validator->validate($callback)) {
throw new HttpException(400, 'Invalid JSONP callback value');
if (!\JsonpCallbackValidator::validate($callback)) {
throw new BadRequestHttpException('Invalid JSONP callback value');
}

$content = '/**/'.$callback.'('.$content.');';
Expand Down

0 comments on commit 9493cbd

Please sign in to comment.