From 9dbc32d7221c7e8a55c38fb86b913d7fe7ddac07 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 6 Apr 2026 20:24:18 +0530 Subject: [PATCH] Harden favicon link parsing --- src/Appwrite/Platform/Modules/Avatars/Http/Favicon/Get.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Avatars/Http/Favicon/Get.php b/src/Appwrite/Platform/Modules/Avatars/Http/Favicon/Get.php index 7d3c98e245..51adf55fb7 100644 --- a/src/Appwrite/Platform/Modules/Avatars/Http/Favicon/Get.php +++ b/src/Appwrite/Platform/Modules/Avatars/Http/Favicon/Get.php @@ -97,7 +97,8 @@ class Get extends Action $space = 0; $linkTags = []; - \preg_match_all('/]*>/i', $res->getBody(), $linkTags); + $html = \preg_replace('//s', '', $res->getBody()) ?? $res->getBody(); + \preg_match_all('/]*>/i', $html, $linkTags); foreach ($linkTags[0] ?? [] as $tag) { $attributes = []; @@ -107,7 +108,7 @@ class Get extends Action foreach ($attributeMatches as $attributeMatch) { $attributes[\strtolower($attributeMatch[1])] = \html_entity_decode( - $attributeMatch[2] ?: $attributeMatch[3] ?: $attributeMatch[4], + $attributeMatch[2] !== '' ? $attributeMatch[2] : ($attributeMatch[3] !== '' ? $attributeMatch[3] : $attributeMatch[4]), \ENT_QUOTES | \ENT_HTML5 ); }