Merge pull request #13099 from MrPetovan/bug/warnings

Address several warnings
This commit is contained in:
Michael Vogel 2023-05-07 08:25:44 +02:00 committed by GitHub
commit 46d3778ee8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 13 deletions

View file

@ -869,7 +869,7 @@ class GServer
} }
// Sanitize incoming data, see https://github.com/friendica/friendica/issues/8565 // Sanitize incoming data, see https://github.com/friendica/friendica/issues/8565
$data['subscribe'] = (bool)$data['subscribe'] ?? false; $data['subscribe'] = (bool)($data['subscribe'] ?? false);
if (!$data['subscribe'] || empty($data['scope']) || !in_array(strtolower($data['scope']), ['all', 'tags'])) { if (!$data['subscribe'] || empty($data['scope']) || !in_array(strtolower($data['scope']), ['all', 'tags'])) {
$data['scope'] = ''; $data['scope'] = '';

View file

@ -31,23 +31,25 @@ use Friendica\Util\Strings;
*/ */
class Hashtag extends BaseModule class Hashtag extends BaseModule
{ {
protected function content(array $request = []): string protected function rawContent(array $request = [])
{ {
$result = []; $result = [];
$t = Strings::escapeHtml($_REQUEST['t']); if (empty($request['t'])) {
if (empty($t)) {
System::jsonExit($result); System::jsonExit($result);
} }
$taglist = DBA::select('tag', ['name'], ["`name` LIKE ?", $t . "%"], ['order' => ['name'], 'limit' => 100]); $taglist = DBA::select(
'tag',
['name'],
["`name` LIKE ?", Strings::escapeHtml($request['t']) . "%"],
['order' => ['name'], 'limit' => 100]
);
while ($tag = DBA::fetch($taglist)) { while ($tag = DBA::fetch($taglist)) {
$result[] = ['text' => $tag['name']]; $result[] = ['text' => $tag['name']];
} }
DBA::close($taglist); DBA::close($taglist);
System::jsonExit($result); System::jsonExit($result);
return '';
} }
} }

View file

@ -103,7 +103,7 @@ class Feed
$xpath->registerNamespace('poco', ActivityNamespace::POCO); $xpath->registerNamespace('poco', ActivityNamespace::POCO);
$author = []; $author = [];
$atomns = ''; $atomns = 'atom';
$entries = null; $entries = null;
$protocol = Conversation::PARCEL_UNKNOWN; $protocol = Conversation::PARCEL_UNKNOWN;
@ -128,13 +128,12 @@ class Feed
// Is it Atom? // Is it Atom?
if ($xpath->query('/atom:feed')->length > 0) { if ($xpath->query('/atom:feed')->length > 0) {
$protocol = Conversation::PARCEL_ATOM; $protocol = Conversation::PARCEL_ATOM;
$atomns = 'atom';
} elseif ($xpath->query('/atom03:feed')->length > 0) { } elseif ($xpath->query('/atom03:feed')->length > 0) {
$protocol = Conversation::PARCEL_ATOM03; $protocol = Conversation::PARCEL_ATOM03;
$atomns = 'atom03'; $atomns = 'atom03';
} }
if (!empty($atomns)) { if (in_array($protocol, [Conversation::PARCEL_ATOM, Conversation::PARCEL_ATOM03])) {
$alternate = XML::getFirstAttributes($xpath, $atomns . ":link[@rel='alternate']"); $alternate = XML::getFirstAttributes($xpath, $atomns . ":link[@rel='alternate']");
if (is_object($alternate)) { if (is_object($alternate)) {
foreach ($alternate as $attribute) { foreach ($alternate as $attribute) {
@ -336,7 +335,7 @@ class Feed
case 'text': case 'text':
$body = $attribute->nodeValue; $body = $attribute->nodeValue;
break; break;
case 'htmlUrl': case 'htmlUrl':
$plink = $attribute->nodeValue; $plink = $attribute->nodeValue;
break; break;
@ -344,7 +343,7 @@ class Feed
case 'xmlUrl': case 'xmlUrl':
$uri = $attribute->nodeValue; $uri = $attribute->nodeValue;
break; break;
case 'type': case 'type':
$isrss = $attribute->nodeValue == 'rss'; $isrss = $attribute->nodeValue == 'rss';
break; break;
@ -507,7 +506,7 @@ class Feed
$attachment['type'] = Post\Media::DOCUMENT; $attachment['type'] = Post\Media::DOCUMENT;
} }
$attachments[] = $attachment; $attachments[] = $attachment;
} }
} }
} }