aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-02-04 10:03:38 +0100
committerMario Vavti <mario@mariovavti.com>2019-02-04 10:03:38 +0100
commitcf80f03084a2bdb0764f25a55c7b6707d2b3ef81 (patch)
tree5e07935656f5e17258a773e41da4aa206648dfb5
parentd97043725d3a38da9686dbf9501272d175e5420a (diff)
parent47f31eed37b8cc94805d01b2ab661d69cc24fa38 (diff)
downloadvolse-hubzilla-cf80f03084a2bdb0764f25a55c7b6707d2b3ef81.tar.gz
volse-hubzilla-cf80f03084a2bdb0764f25a55c7b6707d2b3ef81.tar.bz2
volse-hubzilla-cf80f03084a2bdb0764f25a55c7b6707d2b3ef81.zip
Merge remote-tracking branch 'mike/master' into dev
-rw-r--r--Zotlabs/Lib/Activity.php7
-rw-r--r--Zotlabs/Module/Admin/Site.php2
-rw-r--r--Zotlabs/Module/Events.php4
-rw-r--r--Zotlabs/Module/Item.php4
-rw-r--r--Zotlabs/Module/Mail.php4
-rw-r--r--Zotlabs/Module/Photos.php2
-rw-r--r--Zotlabs/Module/Profiles.php28
-rwxr-xr-xinclude/items.php2
-rw-r--r--include/message.php2
-rw-r--r--include/photos.php2
-rw-r--r--include/text.php162
-rw-r--r--tests/unit/get_tags_test.php17
12 files changed, 139 insertions, 97 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 8cfa18997..259419f54 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -1411,6 +1411,9 @@ class Activity {
$s['owner_xchan'] = $act->actor['id'];
$s['author_xchan'] = $act->actor['id'];
+ // ensure we store the original actor
+ self::actor_store($act->actor['id'],$act->actor);
+
$s['mid'] = $act->obj['id'];
$s['parent_mid'] = $act->parent_id;
@@ -1483,7 +1486,8 @@ class Activity {
$s['verb'] = self::activity_decode_mapper($act->type);
- if($act->type === 'Tombstone') {
+
+ if($act->type === 'Tombstone' || ($act->type === 'Create' && $act->obj['type'] === 'Tombstone')) {
$s['item_deleted'] = 1;
}
@@ -1492,7 +1496,6 @@ class Activity {
$s['obj_type'] = ACTIVITY_OBJ_COMMENT;
}
-
if($act->obj['type'] === 'Event') {
$s['obj'] = [];
$s['obj']['asld'] = $act->obj;
diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php
index 09b038729..55c8ca928 100644
--- a/Zotlabs/Module/Admin/Site.php
+++ b/Zotlabs/Module/Admin/Site.php
@@ -119,7 +119,7 @@ class Site {
del_config('system', 'admininfo');
} else {
require_once('include/text.php');
- linkify_tags($a, $admininfo, local_channel());
+ linkify_tags($admininfo, local_channel());
set_config('system', 'admininfo', $admininfo);
}
set_config('system','siteinfo',$siteinfo);
diff --git a/Zotlabs/Module/Events.php b/Zotlabs/Module/Events.php
index 7e5204e62..e883db49f 100644
--- a/Zotlabs/Module/Events.php
+++ b/Zotlabs/Module/Events.php
@@ -97,8 +97,8 @@ class Events extends \Zotlabs\Web\Controller {
$type = escape_tags(trim($_POST['type']));
require_once('include/text.php');
- linkify_tags($a, $desc, local_channel());
- linkify_tags($a, $location, local_channel());
+ linkify_tags($desc, local_channel());
+ linkify_tags($location, local_channel());
//$action = ($event_hash == '') ? 'new' : "event/" . $event_hash;
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 24949c626..a48a25e03 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -553,8 +553,8 @@ class Item extends Controller {
// Look for tags and linkify them
- $results = linkify_tags($a, $summary, ($uid) ? $uid : $profile_uid);
- $results = linkify_tags($a, $body, ($uid) ? $uid : $profile_uid);
+ $results = linkify_tags($summary, ($uid) ? $uid : $profile_uid);
+ $results = linkify_tags($body, ($uid) ? $uid : $profile_uid);
if($results) {
diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php
index d38c1d88c..3202d38a5 100644
--- a/Zotlabs/Module/Mail.php
+++ b/Zotlabs/Module/Mail.php
@@ -34,7 +34,7 @@ class Mail extends \Zotlabs\Web\Controller {
}
else {
$body = cleanup_bbcode($body);
- $results = linkify_tags($a, $body, local_channel());
+ $results = linkify_tags($body, local_channel());
if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) {
$attachments = array();
@@ -111,7 +111,7 @@ class Mail extends \Zotlabs\Web\Controller {
}
require_once('include/text.php');
- linkify_tags($a, $body, local_channel());
+ linkify_tags($body, local_channel());
if(! $recipient) {
diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php
index 3833d5088..a761dbd14 100644
--- a/Zotlabs/Module/Photos.php
+++ b/Zotlabs/Module/Photos.php
@@ -422,7 +422,7 @@ class Photos extends \Zotlabs\Web\Controller {
require_once('include/text.php');
$profile_uid = \App::$profile['profile_uid'];
- $results = linkify_tags($a, $rawtags, (local_channel()) ? local_channel() : $profile_uid);
+ $results = linkify_tags($rawtags, (local_channel()) ? local_channel() : $profile_uid);
$success = $results['success'];
$post_tags = array();
diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php
index de4075ba9..33e7d8a9d 100644
--- a/Zotlabs/Module/Profiles.php
+++ b/Zotlabs/Module/Profiles.php
@@ -354,20 +354,20 @@ class Profiles extends \Zotlabs\Web\Controller {
require_once('include/text.php');
- linkify_tags($a, $likes, local_channel());
- linkify_tags($a, $dislikes, local_channel());
- linkify_tags($a, $about, local_channel());
- linkify_tags($a, $interest, local_channel());
- linkify_tags($a, $interest, local_channel());
- linkify_tags($a, $contact, local_channel());
- linkify_tags($a, $channels, local_channel());
- linkify_tags($a, $music, local_channel());
- linkify_tags($a, $book, local_channel());
- linkify_tags($a, $tv, local_channel());
- linkify_tags($a, $film, local_channel());
- linkify_tags($a, $romance, local_channel());
- linkify_tags($a, $work, local_channel());
- linkify_tags($a, $education, local_channel());
+ linkify_tags($likes, local_channel());
+ linkify_tags($dislikes, local_channel());
+ linkify_tags($about, local_channel());
+ linkify_tags($interest, local_channel());
+ linkify_tags($interest, local_channel());
+ linkify_tags($contact, local_channel());
+ linkify_tags($channels, local_channel());
+ linkify_tags($music, local_channel());
+ linkify_tags($book, local_channel());
+ linkify_tags($tv, local_channel());
+ linkify_tags($film, local_channel());
+ linkify_tags($romance, local_channel());
+ linkify_tags($work, local_channel());
+ linkify_tags($education, local_channel());
$with = ((x($_POST,'with')) ? escape_tags(trim($_POST['with'])) : '');
diff --git a/include/items.php b/include/items.php
index 1fe98c119..76ae79e6f 100755
--- a/include/items.php
+++ b/include/items.php
@@ -4561,7 +4561,7 @@ function set_linkified_perms($linkified, &$str_contact_allow, &$str_group_allow,
$first_access_tag = true;
foreach($linkified as $x) {
- $access_tag = $x['access_tag'];
+ $access_tag = $x['success']['access_tag'];
if(($access_tag) && (! $parent_item)) {
logger('access_tag: ' . $tag . ' ' . print_r($access_tag,true), LOGGER_DATA);
if ($first_access_tag && (! get_pconfig($profile_uid,'system','no_private_mention_acl_override'))) {
diff --git a/include/message.php b/include/message.php
index 936c01631..037c59c60 100644
--- a/include/message.php
+++ b/include/message.php
@@ -44,7 +44,7 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep
$body = cleanup_bbcode($body);
- $results = linkify_tags($a, $body, $uid);
+ $results = linkify_tags($body, $uid);
if(! $raw) {
if(preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",((strpos($body,'[/crypt]')) ? $_POST['media_str'] : $body),$match)) {
diff --git a/include/photos.php b/include/photos.php
index ae51703e0..44406e0b0 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -356,7 +356,7 @@ function photo_upload($channel, $observer, $args) {
$large_photos = feature_enabled($channel['channel_id'], 'large_photos');
- linkify_tags($a, $args['body'], $channel_id);
+ linkify_tags($args['body'], $channel_id);
if($large_photos) {
$scale = 1;
diff --git a/include/text.php b/include/text.php
index ad7678483..b017b038a 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2631,8 +2631,9 @@ function extra_query_args() {
* @param boolean $in_network default true
* @return boolean true if replaced, false if not replaced
*/
-function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $in_network = true) {
+function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) {
+ $channel = App::get_channel();
$replaced = false;
$r = null;
$match = array();
@@ -2688,21 +2689,20 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
$str_tags .= $newtag;
}
- return [
- 'replaced' => $replaced,
- 'termtype' => $termtype,
- 'term' => $basetag,
- 'url' => $url,
- 'contact' => []
- ];
-
+ return [ [
+ 'replaced' => $replaced,
+ 'termtype' => $termtype,
+ 'term' => $basetag,
+ 'url' => $url,
+ 'contact' => [],
+ 'access_tag' => '',
+ ]];
}
// END hashtags
// BEGIN mentions
-
if ( in_array($termtype, [ TERM_MENTION, TERM_FORUM ] )) {
// The @! tag and !! tag will alter permissions
@@ -2713,7 +2713,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
$exclusive = (((strpos(substr($tag,1), '!') === 0) && $in_network) ? true : false);
//is it already replaced?
- if(strpos($tag,'[zrl=') || strpos($tag,'[url='))
+ if(strpos($tag,"[zrl=") || strpos($tag,"[url="))
return $replaced;
// get the channel name
@@ -2731,7 +2731,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
$newname = substr($name,1);
$newname = substr($newname,0,-1);
- $r = q("select * from xchan where xchan_addr = '%s' or xchan_url = '%s' limit 1",
+ $r = q("select * from xchan where xchan_addr = '%s' or xchan_url = '%s'",
dbesc($newname),
dbesc($newname)
);
@@ -2754,7 +2754,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
// select someone from this user's contacts by name
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE xchan_name = '%s' AND abook_channel = %d LIMIT 1",
+ WHERE xchan_name = '%s' AND abook_channel = %d ",
dbesc($newname),
intval($profile_uid)
);
@@ -2763,7 +2763,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
if((! $r) && strpos($newname,'@')) {
$r = q("SELECT * FROM xchan left join hubloc on xchan_hash = hubloc_hash
- WHERE hubloc_addr = '%s' LIMIT 1",
+ WHERE hubloc_addr = '%s' ",
dbesc($newname)
);
}
@@ -2772,7 +2772,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
if(! $r) {
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE xchan_addr like ('%s') AND abook_channel = %d LIMIT 1",
+ WHERE xchan_addr like ('%s') AND abook_channel = %d ",
dbesc(((strpos($newname,'@')) ? $newname : $newname . '@%')),
intval($profile_uid)
);
@@ -2780,17 +2780,62 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
}
- // $r is set if we found something
- $channel = App::get_channel();
+
+
+
+ $fn_results = [];
+ $access_tag = EMPTY_STR;
+
+
+ // $r is set if we found something
if($r) {
- $profile = $r[0]['xchan_url'];
- $newname = $r[0]['xchan_name'];
- // add the channel's xchan_hash to $access_tag if exclusive
- if($exclusive) {
- $access_tag .= 'cid:' . $r[0]['xchan_hash'];
+ foreach($r as $xc) {
+ $profile = $xc['xchan_url'];
+ $newname = $xc['xchan_name'];
+ // add the channel's xchan_hash to $access_tag if exclusive
+ if($exclusive) {
+ $access_tag = 'cid:' . $xc['xchan_hash'];
+ }
+
+ // if there is a url for this channel
+
+ if(isset($profile)) {
+ $replaced = true;
+ //create profile link
+ $profile = str_replace(',','%2c',$profile);
+ $url = $profile;
+ if($termtype === TERM_FORUM) {
+ $newtag = '!' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
+ $body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
+ }
+ else {
+ // ( $termtype === TERM_MENTION )
+ $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
+ $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
+ }
+
+ // append tag to str_tags
+ if(! stristr($str_tags,$newtag)) {
+ if(strlen($str_tags))
+ $str_tags .= ',';
+ $str_tags .= $newtag;
+ }
+ }
+
+
+ $fn_results[] = [
+ 'replaced' => $replaced,
+ 'termtype' => $termtype,
+ 'term' => $newname,
+ 'url' => $url,
+ 'access_tag' => $access_tag,
+ 'contact' => (($r) ? $xc : []),
+ ];
+
}
+
}
else {
@@ -2802,7 +2847,6 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
// weird - as all the other tags are linked to something.
if(local_channel() && local_channel() == $profile_uid) {
- require_once('include/group.php');
$grp = group_byname($profile_uid,$name);
if($grp) {
@@ -2819,58 +2863,62 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
}
}
}
- }
- // if there is a url for this channel
- if(isset($profile)) {
- $replaced = true;
- //create profile link
- $profile = str_replace(',','%2c',$profile);
- $url = $profile;
- if($termtype === TERM_FORUM) {
- $newtag = '!' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
- $body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
- }
- else {
- // ( $termtype === TERM_MENTION )
- $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
- $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
- }
+ // if there is a url for this channel
- // append tag to str_tags
- if(! stristr($str_tags,$newtag)) {
- if(strlen($str_tags))
- $str_tags .= ',';
- $str_tags .= $newtag;
+ if(isset($profile)) {
+ $replaced = true;
+ //create profile link
+ $profile = str_replace(',','%2c',$profile);
+ $url = $profile;
+ if($termtype === TERM_FORUM) {
+ $newtag = '!' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
+ $body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
+ }
+ else {
+ // ( $termtype === TERM_MENTION )
+ $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
+ $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
+ }
+
+ // append tag to str_tags
+ if(! stristr($str_tags,$newtag)) {
+ if(strlen($str_tags))
+ $str_tags .= ',';
+ $str_tags .= $newtag;
+ }
}
+
+ $fn_results[] = [
+ 'replaced' => $replaced,
+ 'termtype' => $termtype,
+ 'term' => $newname,
+ 'url' => $url,
+ 'access_tag' => $access_tag,
+ 'contact' => [],
+ ];
}
}
+
+ return $fn_results;
- return [
- 'replaced' => $replaced,
- 'termtype' => $termtype,
- 'term' => $newname,
- 'url' => $url,
- 'contact' => (($r) ? $r[0] : [])
- ];
}
-function linkify_tags($a, &$body, $uid, $in_network = true) {
+function linkify_tags(&$body, $uid, $in_network = true) {
$str_tags = EMPTY_STR;
- $tagged = [];
$results = [];
$tags = get_tags($body);
if(count($tags)) {
foreach($tags as $tag) {
- $access_tag = '';
- $success = handle_tag($a, $body, $access_tag, $str_tags, ($uid) ? $uid : App::$profile_uid , $tag, $in_network);
+ $success = handle_tag($body, $str_tags, ($uid) ? $uid : App::$profile_uid , $tag, $in_network);
- $results[] = array('success' => $success, 'access_tag' => $access_tag);
- if($success['replaced']) $tagged[] = $tag;
+ foreach($success as $handled_tag) {
+ $results[] = [ 'success' => $handled_tag ];
+ }
}
}
diff --git a/tests/unit/get_tags_test.php b/tests/unit/get_tags_test.php
index 40f016747..bdffd8311 100644
--- a/tests/unit/get_tags_test.php
+++ b/tests/unit/get_tags_test.php
@@ -106,10 +106,9 @@ class GetTagsTest extends PHPUnit_Framework_TestCase {
$tags=get_tags($text);
- $inform='';
$str_tags='';
foreach($tags as $tag) {
- handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
+ handle_tag($text, $str_tags, 11, $tag);
}
//correct tags found?
@@ -117,7 +116,6 @@ class GetTagsTest extends PHPUnit_Framework_TestCase {
$this->assertTrue(in_array("@Mike", $tags));
//correct output from handle_tag?
- $this->assertEquals("cid:15", $inform);
$this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);
$this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url]", $text);
}
@@ -135,9 +133,8 @@ class GetTagsTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(1, count($tags));
$this->assertTrue(in_array("@Mike.because", $tags));
- $inform='';
$str_tags='';
- handle_tag($this->a, $text, $inform, $str_tags, 11, $tags[0]);
+ handle_tag($text, $str_tags, 11, $tags[0]);
// (mike) - This is a tricky case.
// we support mentions as in @mike@example.com - which contains a period.
@@ -149,7 +146,6 @@ class GetTagsTest extends PHPUnit_Framework_TestCase {
// $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);
// $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url].because", $text);
- $this->assertEquals("", $inform);
$this->assertEquals("", $str_tags);
}
@@ -195,13 +191,11 @@ class GetTagsTest extends PHPUnit_Framework_TestCase {
$this->assertTrue(in_array("@Mike This", $tags));
$this->assertTrue(in_array("#test_case", $tags));
- $inform='';
$str_tags='';
foreach($tags as $tag) {
- handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
+ handle_tag($text, $str_tags, 11, $tag);
}
- $this->assertEquals("cid:15", $inform);
$this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url],#[url=baseurl/search?tag=test%20case]test case[/url]", $str_tags);
$this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url] This is a #[url=baseurl/search?tag=test%20case]test case[/url]", $text);
@@ -255,16 +249,13 @@ class GetTagsTest extends PHPUnit_Framework_TestCase {
//happens right now, but it shouldn't be necessary
$this->assertTrue(in_array("@mike+15 id", $tags));
- $inform='';
$str_tags='';
foreach($tags as $tag) {
- handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
+ handle_tag($text, $str_tags, 11, $tag);
}
$this->assertEquals("Test with @[url=http://justatest.de]Mike Lastname[/url] id tag", $text);
$this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);
- // this test may produce two cid:15 entries - which is OK because duplicates are pruned before delivery
- $this->assertContains("cid:15",$inform);
}
/**