refactor: general code base refactor (#2950)

* refactor

* fix: bug in previous refactor

* chore: exclude phpcompat sniff due to bug in phpcompat

* fix: do not leak absolute paths

* refactor/fix: batch extensions checking, fix DOS issue
This commit is contained in:
Dag 2022-08-06 22:46:28 +02:00 committed by GitHub
parent b042412416
commit 2bbce8ebef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 679 additions and 827 deletions

View file

@ -16,13 +16,17 @@ class DetectAction implements ActionInterface
{
public function execute(array $request)
{
$targetURL = $request['url']
or returnClientError('You must specify a url!');
$targetURL = $request['url'] ?? null;
$format = $request['format'] ?? null;
$format = $request['format']
or returnClientError('You must specify a format!');
if (!$targetURL) {
throw new \Exception('You must specify a url!');
}
if (!$format) {
throw new \Exception('You must specify a format!');
}
$bridgeFactory = new \BridgeFactory();
$bridgeFactory = new BridgeFactory();
foreach ($bridgeFactory->getBridgeClassNames() as $bridgeClassName) {
if (!$bridgeFactory->isWhitelisted($bridgeClassName)) {
@ -31,10 +35,6 @@ class DetectAction implements ActionInterface
$bridge = $bridgeFactory->create($bridgeClassName);
if ($bridge === false) {
continue;
}
$bridgeParams = $bridge->detectParameters($targetURL);
if (is_null($bridgeParams)) {
@ -45,9 +45,9 @@ class DetectAction implements ActionInterface
$bridgeParams['format'] = $format;
header('Location: ?action=display&' . http_build_query($bridgeParams), true, 301);
exit;
return;
}
returnClientError('No bridge found for given URL: ' . $targetURL);
throw new \Exception('No bridge found for given URL: ' . $targetURL);
}
}