Skip to content
Snippets Groups Projects
Commit a758d287 authored by Andrew Dolgov's avatar Andrew Dolgov
Browse files

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
parents f2db34a7 0ce4ae3e
No related branches found
No related tags found
No related merge requests found
......@@ -2074,27 +2074,14 @@ class RSSUtils {
$srcset, $matches, PREG_SET_ORDER
);
foreach ($matches as $m) {
array_push($matches, [
"url" => trim($m["url"]),
"size" => trim($m["size"])
]);
}
return $matches;
return array_map(fn(array $m) => ['url' => trim($m['url']), 'size' => trim($m['size'])], $matches);
}
/**
* @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 {
$tokens = [];
foreach ($matches as $m) {
array_push($tokens, trim($m["url"]) . " " . trim($m["size"]));
}
return implode(",", $tokens);
return implode(',', array_map(fn(array $m) => trim($m['url']) . ' ' . trim($m['size']), $matches));
}
static function function_enabled(string $func): bool {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment