aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-09-22 16:16:50 +0000
committerMario <mario@mariovavti.com>2021-09-22 16:16:50 +0000
commit3347fab105a01f38800a907e7d6281d835a29f5c (patch)
tree8fcf4108bf54875c37b1d3af0f07caf28d536f75
parent33a6c92629f7c58301c15739c1afa4cf612f4d99 (diff)
parent4eb8921635add33215bffc4820f95c34b902f819 (diff)
downloadvolse-hubzilla-3347fab105a01f38800a907e7d6281d835a29f5c.tar.gz
volse-hubzilla-3347fab105a01f38800a907e7d6281d835a29f5c.tar.bz2
volse-hubzilla-3347fab105a01f38800a907e7d6281d835a29f5c.zip
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
-rw-r--r--include/text.php28
1 files changed, 18 insertions, 10 deletions
diff --git a/include/text.php b/include/text.php
index 2d863c5ae..7e1dd13c4 100644
--- a/include/text.php
+++ b/include/text.php
@@ -3216,38 +3216,46 @@ function item_url_replace($channel,&$item,$old,$new,$oldnick = '') {
if($item['attach']) {
json_url_replace($old,$new,$item['attach']);
- if($oldnick)
+ if($oldnick && ($oldnick !== $channel['channel_address']))
json_url_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['attach']);
}
if($item['object']) {
json_url_replace($old,$new,$item['object']);
- if($oldnick)
+ if($oldnick && ($oldnick !== $channel['channel_address']))
json_url_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['object']);
}
if($item['target']) {
json_url_replace($old,$new,$item['target']);
- if($oldnick)
+ if($oldnick && ($oldnick !== $channel['channel_address']))
json_url_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['target']);
}
- $item['body'] = preg_replace("/(\[zrl=".preg_quote($old,'/')."\/(photo|photos|gallery)\/".$channel['channel_address'].".+\]\[zmg=\d+x\d+\])".preg_quote($old,'/')."\/(.+\[\/zmg\])/", '${1}'.$new.'/${3}', $item['body']);
- $item['body'] = preg_replace("/".preg_quote($old,'/')."\/(search|\w+\/".$channel['channel_address'].")/", $new.'/${1}', $item['body']);
+ $root_replaced = null;
+ $nick_replaced = null;
- $item['sig'] = base64url_encode(Crypto::sign($item['body'],$channel['channel_prvkey']));
- $item['item_verified'] = 1;
+ $item['body'] = str_replace($old, $new, $item['body'], $root_replaced);
+
+ if($oldnick && ($oldnick !== $channel['channel_address'])) {
+ $item['body'] = str_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['body'], $nick_replaced);
+ }
+
+ if ($root_replaced || $nick_replaced) {
+ $item['sig'] = Libzot::sign($item['body'], $channel['channel_prvkey']);
+ $item['item_verified'] = 1;
+ }
$item['plink'] = str_replace($old,$new,$item['plink']);
- if($oldnick)
+ if($oldnick && ($oldnick !== $channel['channel_address']))
$item['plink'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['plink']);
$item['llink'] = str_replace($old,$new,$item['llink']);
- if($oldnick)
+ if($oldnick && ($oldnick !== $channel['channel_address']))
$item['llink'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['llink']);
if($item['term']) {
for($x = 0; $x < count($item['term']); $x ++) {
$item['term'][$x]['url'] = str_replace($old,$new,$item['term'][$x]['url']);
- if ($oldnick) {
+ if ($oldnick && ($oldnick !== $channel['channel_address'])) {
$item['term'][$x]['url'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['term'][$x]['url']);
}
}