summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2024-07-10 19:59:38 +0000
committerAndrew Dolgov <fox@fakecake.org>2024-07-10 19:59:38 +0000
commita758d287ffbfb0abbd3e546a05f73cbe0283d181 (patch)
treea2f5fdf86f997cbe78195325fda0542c5cf16f36
parentf2db34a707e8a9cb0683ed5e67071d4bde909e19 (diff)
parent0ce4ae3ececf2cbb19c71e002c98d95af121988d (diff)
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
-rw-r--r--classes/RSSUtils.php17
1 files changed, 2 insertions, 15 deletions
diff --git a/classes/RSSUtils.php b/classes/RSSUtils.php
index 0ba2d18c4..10cfb6d43 100644
--- a/classes/RSSUtils.php
+++ b/classes/RSSUtils.php
@@ -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 {