1
0
mirror of https://tt-rss.org/git/tt-rss.git synced 2024-07-27 16:47:59 +02:00

Merge branch 'bugfix/decoded-srcset-result' into 'master'

Don't reuse the '$matches' array in 'RSSUtils::decode_srcset()'.

See merge request tt-rss/tt-rss!43
This commit is contained in:
Andrew Dolgov 2024-07-10 19:59:38 +00:00
commit a758d287ff

View File

@ -2074,27 +2074,14 @@ class RSSUtils {
$srcset, $matches, PREG_SET_ORDER $srcset, $matches, PREG_SET_ORDER
); );
foreach ($matches as $m) { return array_map(fn(array $m) => ['url' => trim($m['url']), 'size' => trim($m['size'])], $matches);
array_push($matches, [
"url" => trim($m["url"]),
"size" => trim($m["size"])
]);
}
return $matches;
} }
/** /**
* @param array<int, array<string, string>> $matches An array of srcset subitem arrays with keys "url" and "size" * @param array<int, array<string, string>> $matches An array of srcset subitem arrays with keys "url" and "size"
*/ */
static function encode_srcset(array $matches): string { static function encode_srcset(array $matches): string {
$tokens = []; return implode(',', array_map(fn(array $m) => trim($m['url']) . ' ' . trim($m['size']), $matches));
foreach ($matches as $m) {
array_push($tokens, trim($m["url"]) . " " . trim($m["size"]));
}
return implode(",", $tokens);
} }
static function function_enabled(string $func): bool { static function function_enabled(string $func): bool {