mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-05 09:09:37 +00:00
fix: Call to a member function find() on bool (#3146)
* fix: Call to a member function find() on bool Happens when defaultLinkTo() is passed the empty string. * fix: prevent exception in defaultLinkTo() when passed the empty string * refactor
This commit is contained in:
parent
001427243c
commit
dbab225fd2
@ -158,7 +158,10 @@ class GitlabIssueBridge extends BridgeAbstract
|
|||||||
|
|
||||||
$item['timestamp'] = $description->created_at ?? $description->updated_at;
|
$item['timestamp'] = $description->created_at ?? $description->updated_at;
|
||||||
|
|
||||||
$item['author'] = $this->parseAuthor($description_html);
|
$author = $this->parseAuthor($description_html);
|
||||||
|
if ($author) {
|
||||||
|
$item['author'] = $author;
|
||||||
|
}
|
||||||
|
|
||||||
$item['title'] = $description->title;
|
$item['title'] = $description->title;
|
||||||
$item['content'] = markdownToHtml($description->description);
|
$item['content'] = markdownToHtml($description->description);
|
||||||
@ -179,7 +182,10 @@ class GitlabIssueBridge extends BridgeAbstract
|
|||||||
|
|
||||||
$item['timestamp'] = $description_html->find('.merge-request-details time', 0)->datetime;
|
$item['timestamp'] = $description_html->find('.merge-request-details time', 0)->datetime;
|
||||||
|
|
||||||
$item['author'] = $this->parseAuthor($description_html);
|
$author = $this->parseAuthor($description_html);
|
||||||
|
if ($author) {
|
||||||
|
$item['author'] = $author;
|
||||||
|
}
|
||||||
|
|
||||||
$item['title'] = 'Merge Request ' . $description->title;
|
$item['title'] = 'Merge Request ' . $description->title;
|
||||||
$item['content'] = markdownToHtml($description->description);
|
$item['content'] = markdownToHtml($description->description);
|
||||||
@ -205,6 +211,9 @@ class GitlabIssueBridge extends BridgeAbstract
|
|||||||
|
|
||||||
$authors = $description_html->find('.issuable-meta a.author-link, .merge-request a.author-link');
|
$authors = $description_html->find('.issuable-meta a.author-link, .merge-request a.author-link');
|
||||||
$editors = $description_html->find('.edited-text a.author-link');
|
$editors = $description_html->find('.edited-text a.author-link');
|
||||||
|
if ($authors === [] && $editors === []) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
$author_str = implode(' ', $authors);
|
$author_str = implode(' ', $authors);
|
||||||
if ($editors) {
|
if ($editors) {
|
||||||
$author_str .= ', ' . implode(' ', $editors);
|
$author_str .= ', ' . implode(' ', $editors);
|
||||||
|
28
lib/html.php
28
lib/html.php
@ -169,31 +169,35 @@ function backgroundToImg($htmlContent)
|
|||||||
*
|
*
|
||||||
* @link https://github.com/plaidfluff/php-urljoin php-urljoin
|
* @link https://github.com/plaidfluff/php-urljoin php-urljoin
|
||||||
*
|
*
|
||||||
* @param string|object $content The HTML content. Supports HTML objects or string objects
|
* @param string|object $dom The HTML content. Supports HTML objects or string objects
|
||||||
* @param string $server Fully qualified URL to the page containing relative links
|
* @param string $url Fully qualified URL to the page containing relative links
|
||||||
* @return object Content with fixed URLs.
|
* @return string|object Content with fixed URLs.
|
||||||
*/
|
*/
|
||||||
function defaultLinkTo($content, $server)
|
function defaultLinkTo($dom, $url)
|
||||||
{
|
{
|
||||||
|
if ($dom === '') {
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
$string_convert = false;
|
$string_convert = false;
|
||||||
if (is_string($content)) {
|
if (is_string($dom)) {
|
||||||
$string_convert = true;
|
$string_convert = true;
|
||||||
$content = str_get_html($content);
|
$dom = str_get_html($dom);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($content->find('img') as $image) {
|
foreach ($dom->find('img') as $image) {
|
||||||
$image->src = urljoin($server, $image->src);
|
$image->src = urljoin($url, $image->src);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($content->find('a') as $anchor) {
|
foreach ($dom->find('a') as $anchor) {
|
||||||
$anchor->href = urljoin($server, $anchor->href);
|
$anchor->href = urljoin($url, $anchor->href);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($string_convert) {
|
if ($string_convert) {
|
||||||
$content = $content->outertext;
|
$dom = $dom->outertext;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $dom;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user