aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-03-24 02:36:45 -0700
committerfriendica <info@friendica.com>2015-03-24 02:36:45 -0700
commitc024668cf226da7211aaa8cdd04293cf00b8901c (patch)
tree49cf9f788e4d6e325e87dc465e2b4559df68be43 /include
parent37f0bd6c9d98fa57e13dc569ba59332b380471e6 (diff)
downloadvolse-hubzilla-c024668cf226da7211aaa8cdd04293cf00b8901c.tar.gz
volse-hubzilla-c024668cf226da7211aaa8cdd04293cf00b8901c.tar.bz2
volse-hubzilla-c024668cf226da7211aaa8cdd04293cf00b8901c.zip
catche edge case of tag "@abcdef +1", which tags the first entry in your abook, regardless of abcdef. This holds true for other similar patterns as well.
Diffstat (limited to 'include')
-rwxr-xr-xinclude/diaspora.php6
-rw-r--r--include/text.php21
2 files changed, 18 insertions, 9 deletions
diff --git a/include/diaspora.php b/include/diaspora.php
index 1e0e48a86..405fa1e40 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -843,7 +843,7 @@ function diaspora_post($importer,$xml,$msg) {
// Look for tags and linkify them
- $results = linkify_tags(get_app(), $body, $importer['channel_id']);
+ $results = linkify_tags(get_app(), $body, $importer['channel_id'], true);
$datarray['term'] = array();
@@ -1062,7 +1062,7 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray = array();
// Look for tags and linkify them
- $results = linkify_tags(get_app(), $body, $importer['channel_id']);
+ $results = linkify_tags(get_app(), $body, $importer['channel_id'], true);
$datarray['term'] = array();
@@ -1397,7 +1397,7 @@ function diaspora_comment($importer,$xml,$msg) {
$datarray = array();
// Look for tags and linkify them
- $results = linkify_tags(get_app(), $body, $importer['channel_id']);
+ $results = linkify_tags(get_app(), $body, $importer['channel_id'], true);
$datarray['term'] = array();
diff --git a/include/text.php b/include/text.php
index a21d8029f..0aba45d14 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2105,7 +2105,7 @@ function extra_query_args() {
*
* @return boolean true if replaced, false if not replaced
*/
-function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
+function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $diaspora = false) {
$replaced = false;
$r = null;
@@ -2173,7 +2173,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
if(strpos($tag,'@') === 0) {
// The @! tag will alter permissions
- $exclusive = ((strpos($tag,'!') === 1) ? true : false);
+ $exclusive = ((strpos($tag,'!') === 1 && (! $diaspora)) ? true : false);
//is it already replaced?
if(strpos($tag,'[zrl='))
@@ -2202,10 +2202,19 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
// Here we're looking for an address book entry as provided by the auto-completer
// of the form something+nnn where nnn is an abook_id or the first chars of xchan_hash
- if(strrpos($newname,'+')) {
+
+ // If there's a +nnn in the string make sure there isn't a space preceding it
+
+ $t1 = strpos($newname,' ');
+ $t2 = strrpos($newname,'+');
+
+ if($t1 && $t2 && $t1 < $t2)
+ $t2 = 0;
+
+ if(($t2) && (! $diaspora)) {
//get the id
- $tagcid = substr($newname,strrpos($newname,'+') + 1);
+ $tagcid = substr($newname,$t2 + 1);
if(strrpos($tagcid,' '))
$tagcid = substr($tagcid,0,strrpos($tagcid,' '));
@@ -2350,7 +2359,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
return array('replaced' => $replaced, 'termtype' => $termtype, 'term' => $newname, 'url' => $url, 'contact' => $r[0]);
}
-function linkify_tags($a, &$body, $uid) {
+function linkify_tags($a, &$body, $uid, $diaspora = false) {
$str_tags = '';
$tagged = array();
$results = array();
@@ -2374,7 +2383,7 @@ function linkify_tags($a, &$body, $uid) {
if($fullnametagged)
continue;
- $success = handle_tag($a, $body, $access_tag, $str_tags, ($uid) ? $uid : $a->profile_uid , $tag);
+ $success = handle_tag($a, $body, $access_tag, $str_tags, ($uid) ? $uid : $a->profile_uid , $tag, $diaspora);
$results[] = array('success' => $success, 'access_tag' => $access_tag);
if($success['replaced']) $tagged[] = $tag;
}