aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-03-10 11:14:03 +0000
committerMario <mario@mariovavti.com>2021-03-10 11:14:03 +0000
commitc8050ea86587b460769a32be5c55a91fb91c2414 (patch)
tree1579f58a6065e73ddf5dbbefedcc4d8e0bca9e08 /include
parent15faf01ec960fff88a1f9c83fb6d251319cecea7 (diff)
parent11d831e4d7bd4163ea518892f541252ce1acea2e (diff)
downloadvolse-hubzilla-c8050ea86587b460769a32be5c55a91fb91c2414.tar.gz
volse-hubzilla-c8050ea86587b460769a32be5c55a91fb91c2414.tar.bz2
volse-hubzilla-c8050ea86587b460769a32be5c55a91fb91c2414.zip
Merge branch 'php8fixes' into 'dev'
More PHP 8 fixes See merge request hubzilla/core!1923
Diffstat (limited to 'include')
-rw-r--r--include/html2plain.php47
-rw-r--r--include/network.php12
2 files changed, 41 insertions, 18 deletions
diff --git a/include/html2plain.php b/include/html2plain.php
index 91a1f14cb..bf8581bdb 100644
--- a/include/html2plain.php
+++ b/include/html2plain.php
@@ -76,28 +76,47 @@ function quotelevel($message, $wraplength = 75)
return(implode("\n", $newlines));
}
+
function collecturls($message) {
+
$pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
preg_match_all($pattern, $message, $result, PREG_SET_ORDER);
-
- $urls = array();
- foreach ($result as $treffer) {
- // A list of some links that should be ignored
- $list = array("/user/", "/tag/", "/group/", "/profile/", "/channel/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
- "//facebook.com/profile.php?id=", "//plus.google.com/");
- foreach ($list as $listitem)
- if (strpos($treffer[1], $listitem) !== false)
- $ignore = true;
-
- if ((strpos($treffer[1], "//plus.google.com/") !== false) and (strpos($treffer[1], "/posts") !== false))
+
+ $urls = [];
+ if ($result) {
+ $ignore = false;
+ foreach ($result as $treffer) {
+ // A list of some links that should be ignored
+ $list = [
+ "/user/",
+ "/tag/",
+ "/group/",
+ "/profile/",
+ "/channel/",
+ "/search?search=",
+ "/search?tag=",
+ "mailto:",
+ "/u/",
+ "/node/",
+ "//facebook.com/profile.php?id=",
+ "//plus.google.com/"
+ ];
+ foreach ($list as $listitem)
+ if (strpos($treffer[1], $listitem) !== false)
+ $ignore = true;
+
+ if ((strpos($treffer[1], "//plus.google.com/") !== false) and (strpos($treffer[1], "/posts") !== false))
$ignore = false;
-
- if (!$ignore)
- $urls[$treffer[1]] = $treffer[1];
+
+ if (! $ignore)
+ $urls[$treffer[1]] = $treffer[1];
+ }
}
+
return($urls);
}
+
function html2plain($html, $wraplength = 75, $compact = false)
{
diff --git a/include/network.php b/include/network.php
index f5ff48fce..fcc7b4289 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1134,11 +1134,15 @@ function discover_by_webbie($webbie, $protocol = '') {
foreach($x['links'] as $link) {
if(array_key_exists('rel',$link)) {
if($link['rel'] === PROTOCOL_ZOT6 && ((! $protocol) || (strtolower($protocol) === 'zot6'))) {
+
logger('zot6 found for ' . $webbie, LOGGER_DEBUG);
$record = Zotfinger::exec($link['href']);
+ if (! $record) {
+ logger('Record not found for ' . $link['href']);
+ continue;
+ }
// Check the HTTP signature
-
$hsig = $record['signature'];
if($hsig && $hsig['signer'] === $link['href'] && $hsig['header_valid'] === true && $hsig['content_valid'] === true)
$hsig_valid = true;
@@ -1226,7 +1230,7 @@ function webfinger_rfc7033($webbie, $zot = false) {
if($m['scheme'] !== 'https')
return false;
- $rhs = $m['host'] . (($m['port']) ? ':' . $m['port'] : '');
+ $rhs = $m['host'] . (array_key_exists('port', $m) ? ':' . $m['port'] : '');
$resource = urlencode($webbie);
}
}
@@ -1957,10 +1961,10 @@ function service_plink($contact, $guid) {
$m = parse_url($contact['xchan_url']);
if($m) {
- $url = $m['scheme'] . '://' . $m['host'] . (($m['port']) ? ':' . $m['port'] : '');
+ $url = $m['scheme'] . '://' . $m['host'] . (array_key_exists('port', $m) ? ':' . $m['port'] : '');
}
else {
- $url = 'https://' . substr($contact['xchan_addr'],strpos($contact['xchan_addr'],'@')+1);
+ $url = 'https://' . substr($contact['xchan_addr'], strpos($contact['xchan_addr'], '@') + 1);
}
$handle = substr($contact['xchan_addr'], 0, strpos($contact['xchan_addr'],'@'));