fix: parse native image media urls
This commit is contained in:
Vendored
+6
-2
@@ -627,7 +627,11 @@ function formatWebGroupMessage(
|
|||||||
|
|
||||||
function cleanupNativeMediaUrl(string $url): string
|
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
|
function nativeMediaUrlScore(string $url): int
|
||||||
@@ -655,7 +659,7 @@ function extractNativeMediaUrlFromData($data): string
|
|||||||
if (!is_string($data) || $data === '') {
|
if (!is_string($data) || $data === '') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (!preg_match_all("~https?://[^\\s\"'<>\\x00]+~i", $data, $matches)) {
|
if (!preg_match_all("~https?://[^\\s\"'<>\\x00-\\x1F\\x7F]+~i", $data, $matches)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -627,7 +627,11 @@ function formatWebGroupMessage(
|
|||||||
|
|
||||||
function cleanupNativeMediaUrl(string $url): string
|
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
|
function nativeMediaUrlScore(string $url): int
|
||||||
@@ -655,7 +659,7 @@ function extractNativeMediaUrlFromData($data): string
|
|||||||
if (!is_string($data) || $data === '') {
|
if (!is_string($data) || $data === '') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (!preg_match_all("~https?://[^\\s\"'<>\\x00]+~i", $data, $matches)) {
|
if (!preg_match_all("~https?://[^\\s\"'<>\\x00-\\x1F\\x7F]+~i", $data, $matches)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user