aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Activity.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2023-06-12 19:05:37 +0000
committerMario <mario@mariovavti.com>2023-06-12 19:05:37 +0000
commit6989a3eaadd676c5c1b5fd523c4196d289423471 (patch)
tree358c82f1bc8205c584ca637c1132e01e25aa2d06 /Zotlabs/Lib/Activity.php
parent59b217f7eaf4d5efd08ca8db82866b38ce1f5cf4 (diff)
downloadvolse-hubzilla-6989a3eaadd676c5c1b5fd523c4196d289423471.tar.gz
volse-hubzilla-6989a3eaadd676c5c1b5fd523c4196d289423471.tar.bz2
volse-hubzilla-6989a3eaadd676c5c1b5fd523c4196d289423471.zip
fix string replacement if a match is available more than once
Diffstat (limited to 'Zotlabs/Lib/Activity.php')
-rw-r--r--Zotlabs/Lib/Activity.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 8bb157347..dbf7f7b46 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -468,14 +468,17 @@ class Activity {
$token = get_iconfig($i, 'ocap', 'relay');
if ($token && $has_images) {
+ $matches_processed = [];
for ($n = 0; $n < count($images); $n++) {
$match = $images[$n];
- if (str_starts_with($match[1], '=http') && str_contains($match[1], z_root() . '/photo/')) {
+ if (str_starts_with($match[1], '=http') && str_contains($match[1], z_root() . '/photo/') && !in_array($match[1], $matches_processed)) {
$i['body'] = str_replace($match[1], $match[1] . '?token=' . $token, $i['body']);
$images[$n][2] = substr($match[1], 1) . '?token=' . $token;
- } elseif (str_contains($match[2], z_root() . '/photo/')) {
+ $matches_processed[] = $match[1];
+ } elseif (str_contains($match[2], z_root() . '/photo/') && !in_array($match[2], $matches_processed)) {
$i['body'] = str_replace($match[2], $match[2] . '?token=' . $token, $i['body']);
$images[$n][2] = $match[2] . '?token=' . $token;
+ $matches_processed[] = $match[2];
}
}
}