fix: parse native image media urls

This commit is contained in:
winchen
2026-07-31 21:16:31 +08:00
parent 21e1ae23c1
commit 0d3d410bd2
2 changed files with 12 additions and 4 deletions
+6 -2
View File
@@ -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 '';
}