diff --git a/dist/api/messages.php b/dist/api/messages.php index 0727371..a3feffe 100644 --- a/dist/api/messages.php +++ b/dist/api/messages.php @@ -627,7 +627,11 @@ function formatWebGroupMessage( function cleanupNativeMediaUrl(string $url): string { - return rtrim($url, " \t\r\n\0\x0B\"'<>.,;)]}"); + // WildFire's protobuf payload places the next field tag (0x40, "@") + // and a control byte immediately after remoteMediaUrl. Keep this helper + // defensive if it receives an unbounded match from older payloads. + $url = preg_replace('/[\x00-\x1F\x7F].*$/s', '', $url) ?? $url; + return rtrim($url, " \t\r\n\0\x0B\"'<>.,;)]}@"); } function nativeMediaUrlScore(string $url): int @@ -655,7 +659,7 @@ function extractNativeMediaUrlFromData($data): string if (!is_string($data) || $data === '') { return ''; } - if (!preg_match_all("~https?://[^\\s\"'<>\\x00]+~i", $data, $matches)) { + if (!preg_match_all("~https?://[^\\s\"'<>\\x00-\\x1F\\x7F]+~i", $data, $matches)) { return ''; } diff --git a/public/api/messages.php b/public/api/messages.php index 0727371..a3feffe 100644 --- a/public/api/messages.php +++ b/public/api/messages.php @@ -627,7 +627,11 @@ function formatWebGroupMessage( function cleanupNativeMediaUrl(string $url): string { - return rtrim($url, " \t\r\n\0\x0B\"'<>.,;)]}"); + // WildFire's protobuf payload places the next field tag (0x40, "@") + // and a control byte immediately after remoteMediaUrl. Keep this helper + // defensive if it receives an unbounded match from older payloads. + $url = preg_replace('/[\x00-\x1F\x7F].*$/s', '', $url) ?? $url; + return rtrim($url, " \t\r\n\0\x0B\"'<>.,;)]}@"); } function nativeMediaUrlScore(string $url): int @@ -655,7 +659,7 @@ function extractNativeMediaUrlFromData($data): string if (!is_string($data) || $data === '') { return ''; } - if (!preg_match_all("~https?://[^\\s\"'<>\\x00]+~i", $data, $matches)) { + if (!preg_match_all("~https?://[^\\s\"'<>\\x00-\\x1F\\x7F]+~i", $data, $matches)) { return ''; }