aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/bbcode.php27
-rw-r--r--include/conversation.php6
-rw-r--r--include/html2plain.php47
-rw-r--r--include/items.php6
-rw-r--r--include/network.php12
5 files changed, 69 insertions, 29 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index a5ef6760b..388a828c4 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -152,6 +152,18 @@ function bb_spacefy($st) {
}
// The previously spacefied [noparse][ i ]italic[ /i ][/noparse],
+// now turns back returning [noparse][i]italic[/i][/noparse]
+function bb_unspacefy($st) {
+ $whole_match = $st[0];
+ $captured = $st[1];
+ $spacefied = preg_replace("/\[ (.*?) \]/", "[$1]", $captured);
+ $new_str = str_replace($captured, $spacefied, $whole_match);
+
+ return $new_str;
+}
+
+
+// The previously spacefied [noparse][ i ]italic[ /i ][/noparse],
// now turns back and the [noparse] tags are trimmed
// returning [i]italic[/i]
@@ -1097,6 +1109,9 @@ function bbcode($Text, $options = []) {
if (strpos($Text,'[pre]') !== false) {
$Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$Text);
}
+ if (strpos($Text,'[summary]') !== false) {
+ $Text = preg_replace_callback("/\[summary\](.*?)\[\/summary\]/ism", 'bb_spacefy',$Text);
+ }
$Text = bb_format_attachdata($Text);
@@ -1438,11 +1453,6 @@ function bbcode($Text, $options = []) {
$Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm", "<span style=\"font-family: $1;\">$2</span>", $Text);
}
-
- if(strpos($Text,'[/summary]') !== false) {
- $Text = preg_replace_callback("/^(.*?)\[summary\](.*?)\[\/summary\](.*?)$/is", 'bb_summary', $Text);
- }
-
// Check for [spoiler] text
$endlessloop = 0;
while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler]") !== false) and (++$endlessloop < 20)) {
@@ -1611,6 +1621,13 @@ function bbcode($Text, $options = []) {
}
+ if (strpos($Text,'[summary]') !== false) {
+ $Text = preg_replace_callback("/\[summary\](.*?)\[\/summary\]/ism", 'bb_unspacefy',$Text);
+ }
+ if(strpos($Text,'[/summary]') !== false) {
+ $Text = preg_replace_callback("/^(.*?)\[summary\](.*?)\[\/summary\](.*?)$/is", 'bb_summary', $Text);
+ }
+
// Unhide all [noparse] contained bbtags unspacefying them
// and triming the [noparse] tag.
if (strpos($Text,'[noparse]') !== false) {
diff --git a/include/conversation.php b/include/conversation.php
index ae69b7a01..f3e5fafa7 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -865,7 +865,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
$x = [ 'mode' => $mode, 'item' => $item ];
call_hooks('stream_item',$x);
- if($x['item']['blocked'])
+ if(isset($x['item']['blocked']))
continue;
$item = $x['item'];
@@ -1563,7 +1563,7 @@ function sort_item_children($items) {
$result = $items;
usort($result,'sort_thr_created_rev');
foreach($result as $k => $i) {
- if($result[$k]['children']) {
+ if(isset($result[$k]['children'])) {
$result[$k]['children'] = sort_item_children($result[$k]['children']);
}
}
@@ -1573,7 +1573,7 @@ function sort_item_children($items) {
function add_children_to_list($children, &$arr) {
foreach($children as $y) {
$arr[] = $y;
- if($y['children'])
+ if(isset($y['children']))
add_children_to_list($y['children'], $arr);
}
}
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/items.php b/include/items.php
index a1198bb4d..c6a5f40a6 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1432,7 +1432,7 @@ function purify_imported_object($obj) {
elseif (is_string($obj)) {
$ret = purify_html($obj);
}
-
+
return $ret;
}
@@ -4334,8 +4334,8 @@ function fetch_post_tags($items, $link = false) {
foreach($imeta as $i) {
if(array_key_exists('item_id',$items[$x])) {
if($i['iid'] == $items[$x]['item_id']) {
- if(! is_array($items[$x]['iconfig']))
- $items[$x]['iconfig'] = array();
+ if(! isset($items[$x]['iconfig']))
+ $items[$x]['iconfig'] = [];
$i['v'] = ((preg_match('|^a:[0-9]+:{.*}$|s',$i['v'])) ? unserialize($i['v']) : $i['v']);
$items[$x]['iconfig'][] = $i;
}
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'],'@'));