Skip to content

Commit ff7148d

Browse files
committed
[TASK] Add additional checks
1 parent 703ca3c commit ff7148d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Classes/Controller/AjaxController.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Psr\Http\Message\ServerRequestInterface;
99
use TYPO3\CMS\Core\Http\JsonResponse;
1010
use TYPO3\CMS\Core\Utility\GeneralUtility;
11+
use TYPO3\CMS\Core\Utility\StringUtility;
1112

1213
class AjaxController
1314
{
@@ -18,15 +19,17 @@ public function checkAction(ServerRequestInterface $request): JsonResponse
1819
$response = [];
1920
$parser = GeneralUtility::makeInstance(UrlParser::class);
2021

21-
try {
22-
$newValue = $parser->parse($uri);
23-
if ($newValue !== $uri) {
24-
$response['transformed'] = $newValue;
25-
$response['status'] = true;
22+
if (is_string($uri) && !empty($uri) && (StringUtility::beginsWith($uri, 'http') || StringUtility::beginsWith($uri, '/'))) {
23+
try {
24+
$newValue = $parser->parse($uri);
25+
if ($newValue !== $uri) {
26+
$response['transformed'] = $newValue;
27+
$response['status'] = true;
28+
}
29+
} catch (\Exception $exception) {
30+
$response['false'] = true;
31+
$response['message'] = $exception->getMessage();
2632
}
27-
} catch (\Exception $exception) {
28-
$response['false'] = true;
29-
$response['message'] = $exception->getMessage();
3033
}
3134
return new JsonResponse($response);
3235
}

0 commit comments

Comments
 (0)