From b359b89aa1f528002e19b46fffc105715dd731c8 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 4 Nov 2019 11:14:44 +0000 Subject: port fixes from zap to check for arrays (cherry picked from commit 7cc8c2d127b09b7e53c7916c6ea104fa566971db) --- Zotlabs/Lib/Activity.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 844127ee3..a2e30e72b 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -401,26 +401,30 @@ class Activity { $ret = []; - if($item['tag']) { - foreach($item['tag'] as $t) { - if(! array_key_exists('type',$t)) + if ($item['tag'] && is_array($item['tag'])) { + $ptr = $item['tag']; + if (! array_key_exists(0,$ptr)) { + $ptr = [ $ptr ]; + } + foreach ($ptr as $t) { + if (! array_key_exists('type',$t)) $t['type'] = 'Hashtag'; switch($t['type']) { case 'Hashtag': - $ret[] = [ 'ttype' => TERM_HASHTAG, 'url' => ((isset($t['href'])) ? $t['href'] : $t['id']), 'term' => escape_tags((substr($t['name'],0,1) === '#') ? substr($t['name'],1) : $t['name']) ]; + $ret[] = [ 'ttype' => TERM_HASHTAG, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'],0,1) === '#') ? substr($t['name'],1) : $t['name']) ]; break; case 'Mention': $mention_type = substr($t['name'],0,1); - if($mention_type === '!') { + if ($mention_type === '!') { $ret[] = [ 'ttype' => TERM_FORUM, 'url' => $t['href'], 'term' => escape_tags(substr($t['name'],1)) ]; } else { $ret[] = [ 'ttype' => TERM_MENTION, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'],0,1) === '@') ? substr($t['name'],1) : $t['name']) ]; } break; - + default: break; } @@ -431,6 +435,7 @@ class Activity { } + static function encode_taxonomy($item) { $ret = []; -- cgit v1.2.3 From 02fd7e51ffeee490760877f2a4f94d9bc8417f69 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 4 Nov 2019 11:33:16 +0000 Subject: add date and request target headers to make pixelfed happy (cherry picked from commit 3604220c2a5aedddf25143cc5fd87ed576d34702) --- Zotlabs/Lib/Activity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 844127ee3..5bad73123 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -87,8 +87,8 @@ class Activity { $headers = [ 'Accept' => 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"', 'Host' => $m['host'], - '(request-target)' => 'get ' . get_request_string($url), - 'Date' => datetime_convert('UTC','UTC','now','D, d M Y H:i:s') . ' UTC' + 'Date' => datetime_convert('UTC','UTC', 'now', 'D, d M Y h:i:s \\G\\M\\T'), + '(request-target)' => 'get ' . get_request_string($url) ]; if (isset($token)) { $headers['Authorization'] = 'Bearer ' . $token; -- cgit v1.2.3 From 09ad48c12bf9eba0bf44229bb8028029102ecfa5 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 4 Nov 2019 21:44:42 +0100 Subject: Prefer use Etag on photo modification validation --- Zotlabs/Module/Photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index fe8c47544..48e2bf4a5 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -221,7 +221,7 @@ class Photo extends \Zotlabs\Web\Controller { header_remove('Pragma'); - if($_SERVER['HTTP_IF_NONE_MATCH'] === $etag || $_SERVER['HTTP_IF_MODIFIED_SINCE'] === gmdate("D, d M Y H:i:s", $modified) . " GMT") { + if((isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] === $etag) || (!isset($_SERVER['HTTP_IF_NONE_MATCH']) && isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] === gmdate("D, d M Y H:i:s", $modified) . " GMT")) { header_remove('Expires'); header_remove('Cache-Control'); header_remove('Set-Cookie'); -- cgit v1.2.3