Skip to content

Commit

Permalink
fix: various fixes (#3745)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvikan authored Oct 12, 2023
1 parent 382648f commit 44fb2c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bridges/CVEDetailsBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function collectData()
$content = $tr->find('.cvesummarylong', 0)->innertext;
$cweList = $detailHtml->find('h2', 2)->next_sibling();
foreach ($cweList->find('li') as $li) {
$cweWithDescription = $li->find('a', 0)->innertext;
$cweWithDescription = $li->find('a', 0)->innertext ?? '';

if (preg_match('/CWE-(\d+)/', $cweWithDescription, $cwe)) {
$categories[] = 'CWE-' . $cwe[1];
Expand Down
18 changes: 10 additions & 8 deletions bridges/CubariBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public function getURI()
*/
public function collectData()
{
$jsonSite = getContents($this->getInput('gist'));
$jsonFile = json_decode($jsonSite, true);
$json = getContents($this->getInput('gist'));
$jsonFile = json_decode($json, true);

$this->mangaTitle = $jsonFile['title'];

Expand All @@ -66,12 +66,14 @@ protected function getEncodedGist()
{
$url = $this->getInput('gist');

preg_match('/\/([a-z]*)\.githubusercontent.com(.*)/', $url, $matches);

// raw or gist is first match.
$unencoded = $matches[1] . $matches[2];

return base64_encode($unencoded);
if (preg_match('/\/([a-z]*)\.githubusercontent.com(.*)/', $url, $matches)) {
// raw or gist is first match.
$unencoded = $matches[1] . $matches[2];
return base64_encode($unencoded);
} else {
// todo: fix this
return '';
}
}

private function getSanitizedHash($string)
Expand Down
7 changes: 5 additions & 2 deletions lib/FeedParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function parseFeed(string $xmlString): array
$feed['items'][] = $this->parseAtomItem($item);
}
} else {
throw new \Exception(sprintf('Unable to detect feed format from `%s`', $url));
throw new \Exception('Unable to detect feed format');
}

return $feed;
Expand Down Expand Up @@ -163,7 +163,9 @@ public function parseRss2Item(\SimpleXMLElement $feedItem): array
}

if (isset($feedItem->enclosure) && !empty($feedItem->enclosure['url'])) {
$item['enclosures'] = [(string)$feedItem->enclosure['url']];
$item['enclosures'] = [
(string)$feedItem->enclosure['url'],
];
}
return $item;
}
Expand All @@ -189,6 +191,7 @@ public function parseRss091Item(\SimpleXMLElement $feedItem): array
{
$item = [];
if (isset($feedItem->link)) {
// todo: trim uri
$item['uri'] = (string)$feedItem->link;
}
if (isset($feedItem->title)) {
Expand Down

0 comments on commit 44fb2c9

Please sign in to comment.