1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-06 16:46:30 +02:00

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
45 changed files with 679 additions and 827 deletions

View File

@@ -43,6 +43,25 @@ class FDroidRepoBridge extends BridgeAbstract
// Stores repo information
private $repo;
public function collectData()
{
if (!extension_loaded('zip')) {
throw new \Exception('FDroidRepoBridge requires the php-zip extension');
}
$this->repo = $this->getRepo();
switch ($this->queriedContext) {
case 'Latest Updates':
$this->getAllUpdates();
break;
case 'Follow Package':
$this->getPackage($this->getInput('package'));
break;
default:
returnServerError('Unimplemented Context (collectData)');
}
}
public function getURI()
{
if (empty($this->queriedContext)) {
@@ -70,21 +89,6 @@ class FDroidRepoBridge extends BridgeAbstract
}
}
public function collectData()
{
$this->repo = $this->getRepo();
switch ($this->queriedContext) {
case 'Latest Updates':
$this->getAllUpdates();
break;
case 'Follow Package':
$this->getPackage($this->getInput('package'));
break;
default:
returnServerError('Unimplemented Context (collectData)');
}
}
private function getRepo()
{
$url = $this->getURI();
@@ -95,9 +99,10 @@ class FDroidRepoBridge extends BridgeAbstract
file_put_contents($jar_loc, $jar);
// JAR files are specially formatted ZIP files
$jar = new ZipArchive();
$jar = new \ZipArchive();
if ($jar->open($jar_loc) !== true) {
returnServerError('Failed to extract archive');
unlink($jar_loc);
throw new \Exception('Failed to extract archive');
}
// Get file pointer to the relevant JSON inside
@@ -109,6 +114,7 @@ class FDroidRepoBridge extends BridgeAbstract
$data = json_decode(stream_get_contents($fp), true);
fclose($fp);
$jar->close();
unlink($jar_loc);
return $data;
}