From 68bd80212ca58c59ac117d123914102f66b4a43f Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 22 Jan 2023 12:13:39 -0800 Subject: [PATCH 1/4] don't block yourself --- include/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/conversation.php b/include/conversation.php index 6000252f0..c2ce7f3ab 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -864,7 +864,7 @@ function thread_author_menu($item, $mode = '') ]; } - if (local_channel()) { + if ($local_channel && $item['author_xchan'] !== $channel['channel_hash']) { $menu[] = [ 'menu' => 'superblocksite', 'title' => t('Block author\'s site'), From b075e87715ea7dcc2f533ff9b9b87d7a482538d0 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Mon, 23 Jan 2023 08:06:58 +1100 Subject: [PATCH 2/4] cleanup --- include/misc.php | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/include/misc.php b/include/misc.php index a2891c712..6a51cba1e 100644 --- a/include/misc.php +++ b/include/misc.php @@ -893,22 +893,22 @@ function get_tags($s) // ignore anything in a code or svg block or HTML tag - $s = preg_replace('/\[code(.*?)\](.*?)\[\/code\]/sm', '', $s); - $s = preg_replace('/\<(.*?)\>/sm', '', $s); - $s = preg_replace('/\[svg(.*?)\](.*?)\[\/svg\]/sm', '', $s); + $s = preg_replace('/\[code(.*?)](.*?)\[\/code]/sm', '', $s); + $s = preg_replace('/<(.*?)>/sm', '', $s); + $s = preg_replace('/\[svg(.*?)](.*?)\[\/svg]/sm', '', $s); // ignore anything in [style= ] - $s = preg_replace('/\[style=(.*?)\]/sm', '', $s); + $s = preg_replace('/\[style=(.*?)]/sm', '', $s); // ignore anything in [color= ], because it may contain color codes which are mistaken for tags - $s = preg_replace('/\[color=(.*?)\]/sm', '', $s); + $s = preg_replace('/\[color=(.*?)]/sm', '', $s); // skip anchors in URL - $s = preg_replace('/\[url=(.*?)\]/sm', '', $s); + $s = preg_replace('/\[url=(.*?)]/sm', '', $s); // match any double quoted tags - if (preg_match_all('/([@#\!]\"\;.*?\"\;)/', $s, $match)) { + if (preg_match_all('/([@#!]".*?")/', $s, $match)) { foreach ($match[1] as $mtch) { $ret[] = $mtch; } @@ -916,7 +916,7 @@ function get_tags($s) // match any unescaped double quoted tags (rare) - if (preg_match_all('/([@#\!]\".*?\")/', $s, $match)) { + if (preg_match_all('/([@#!]\".*?\")/', $s, $match)) { foreach ($match[1] as $mtch) { $ret[] = $mtch; } @@ -924,7 +924,7 @@ function get_tags($s) // match bracket mentions - if (preg_match_all('/([@!]\!?\{.*?\})/', $s, $match)) { + if (preg_match_all('/([@!]!?\{.*?})/', $s, $match)) { foreach ($match[1] as $mtch) { $ret[] = $mtch; } @@ -933,7 +933,7 @@ function get_tags($s) // Pull out single word tags. These can be @nickname, @first_last // and #hash tags. - if (preg_match_all('/(?$1', $s); - $s = preg_replace("/\<(.*?)(src|href)=(.*?)\&\;(.*?)\>/ism", '<$1$2=$3&$4>', $s); + $s = preg_replace("/(https?:\/\/[a-zA-Z0-9\pL:\/\-?&;.=_@~#'%\$!+,]*)/u", '$1', $s); + $s = preg_replace("/<(.*?)(src|href)=(.*?)&(.*?)>/ism", '<$1$2=$3&$4>', $s); return($s); } @@ -1090,7 +1090,7 @@ function sslify($s, $cache_enable = true) // we'll only sslify img tags because media files will probably choke. - $pattern = "/\/"; + $pattern = "//"; $matches = null; $cnt = preg_match_all($pattern, $s, $matches, PREG_SET_ORDER); @@ -1103,7 +1103,7 @@ function sslify($s, $cache_enable = true) return $s; } - $pattern = "/\/ism"; + $pattern = "//ism"; $matches = null; $cnt = preg_match_all($pattern, $s, $matches, PREG_SET_ORDER); @@ -1129,7 +1129,7 @@ function sslify($s, $cache_enable = true) function uncache($s) { - $pattern = "/\/ism"; + $pattern = "//ism"; $matches = null; $cnt = preg_match_all($pattern, $s, $matches, PREG_SET_ORDER); @@ -2137,7 +2137,7 @@ function prepare_text($text, $content_type = 'text/x-multicode', $opts = false) require_once('include/bbcode.php'); if (stristr($text, '[nosmile]')) { - $s = bbcode($text, [ 'cache' => $cache ]); + $s = bbcode($text, ((is_array($opts)) ? $opts : [] )); } else { $s = smilies(bbcode($text, ((is_array($opts)) ? $opts : [] ))); } @@ -2193,6 +2193,7 @@ function get_plink($item, $conversation_mode = true) function layout_select($channel_id, $current = '') { + $options = ''; $r = q( "select mid, v from item left join iconfig on iconfig.iid = item.id where iconfig.cat = 'system' and iconfig.k = 'PDL' and item.uid = %d and item_type = %d ", From c8d7ffc447ff4e40c8ad603a738d510bb440b1e1 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Wed, 25 Jan 2023 07:54:10 +1100 Subject: [PATCH 3/4] give hashtags a type, even though the spec says they are the default type. --- Code/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Lib/Activity.php b/Code/Lib/Activity.php index f0953dd26..71211c2c6 100644 --- a/Code/Lib/Activity.php +++ b/Code/Lib/Activity.php @@ -497,7 +497,7 @@ class Activity case TERM_HASHTAG: // An id is required so if there is no url in the taxonomy, ignore it and keep going. if ($t['url']) { - $ret[] = ['id' => $t['url'], 'name' => '#' . $t['term']]; + $ret[] = [ 'type' => 'Hashtag', id' => $t['url'], 'name' => '#' . $t['term']]; } break; From 01379f6cbfce240aea6a739c10a9e8514725e2ad Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Wed, 25 Jan 2023 07:56:23 +1100 Subject: [PATCH 4/4] misplaced quote --- Code/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Lib/Activity.php b/Code/Lib/Activity.php index 71211c2c6..beaa077b7 100644 --- a/Code/Lib/Activity.php +++ b/Code/Lib/Activity.php @@ -497,7 +497,7 @@ class Activity case TERM_HASHTAG: // An id is required so if there is no url in the taxonomy, ignore it and keep going. if ($t['url']) { - $ret[] = [ 'type' => 'Hashtag', id' => $t['url'], 'name' => '#' . $t['term']]; + $ret[] = [ 'type' => 'Hashtag', 'id' => $t['url'], 'name' => '#' . $t['term']]; } break;