Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Jan 21, 2025
1 parent 132dbc6 commit fb1149a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
22 changes: 14 additions & 8 deletions www/controllers/Gpg.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ public function import(string $gpgKeyUrl, string $gpgKeyFingerprint, string $gpg
throw new Exception('Invalid URL');
}

/**
* If the user specified a URL in the fingerprint field, quit
*/
if (!empty($gpgKeyFingerprint) and preg_match('#^http(s)?://#', $gpgKeyFingerprint)) {
throw new Exception('Invalid fingerprint');
}

try {
/**
* Import GPG key from URL
Expand Down Expand Up @@ -341,7 +348,7 @@ public function import(string $gpgKeyUrl, string $gpgKeyFingerprint, string $gpg
/**
* Import a file-based GPG key
*/
private function importRawContent($fileContent) : array
private function importRawContent(string $fileContent) : array
{
/**
* Quit if user tries to import a GPG from url
Expand Down Expand Up @@ -396,8 +403,7 @@ private function importRawContent($fileContent) : array
}

return $fingerprints;
}
finally {
} finally {
/**
* Delete temp file
*/
Expand Down Expand Up @@ -454,7 +460,7 @@ public function importFromUrl(string $url) : array
curl_setopt($ch, CURLOPT_TIMEOUT, 5); // set timeout
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirect
curl_setopt($ch, CURLOPT_ENCODING, ''); // use compression if any
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // output content to return
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // output content to return

/**
* If a proxy has been specified
Expand All @@ -472,7 +478,8 @@ public function importFromUrl(string $url) : array
*/
throw new Exception('curl error: ' . curl_error($ch));
}
elseif (empty($result)) {

if (empty($result)) {
/**
* If key is empty, meaning bad key
*/
Expand All @@ -494,11 +501,10 @@ public function importFromUrl(string $url) : array
throw new Exception('file could not be downloaded (http return code is: ' . $status["http_code"] . ')');
}
}
}
finally {
} finally {
curl_close($ch);
}

/**
* Import GPG key
*/
Expand Down
8 changes: 5 additions & 3 deletions www/controllers/Repo/Source/Rpm.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ public function addReleasever(int $id, string $name)
/**
* Check that a release version with the same name does not already exist
*/
foreach ($currentParams['releasever'] as $releasever) {
if ($releasever['name'] == $name) {
throw new Exception('Release version ' . $name . ' already exists');
if (!empty($currentParams['releasever'])) {
foreach ($currentParams['releasever'] as $releasever) {
if ($releasever['name'] == $name) {
throw new Exception('Release version ' . $name . ' already exists');
}
}
}

Expand Down

0 comments on commit fb1149a

Please sign in to comment.