diff options
author | friendica <info@friendica.com> | 2014-03-30 20:53:59 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-03-30 20:53:59 -0700 |
commit | 653d7df86df781d50e1bc4b3ed61468563629df2 (patch) | |
tree | cb7824f6cb62962f3a9476cb69f6fca9c9a53582 | |
parent | 3791cee52b43ad1ca1ca5290493734b5971c799c (diff) | |
download | volse-hubzilla-653d7df86df781d50e1bc4b3ed61468563629df2.tar.gz volse-hubzilla-653d7df86df781d50e1bc4b3ed61468563629df2.tar.bz2 volse-hubzilla-653d7df86df781d50e1bc4b3ed61468563629df2.zip |
issue #378, failure to correctly link tags where one tag contains a substring of the other (depends on the order they are discovered).
-rwxr-xr-x | include/items.php | 1 | ||||
-rwxr-xr-x | include/text.php | 18 |
2 files changed, 18 insertions, 1 deletions
diff --git a/include/items.php b/include/items.php index dcf9f5bc2..cf2bdd4f3 100755 --- a/include/items.php +++ b/include/items.php @@ -2294,6 +2294,7 @@ function tag_deliver($uid,$item_id) { logger('tag_deliver: community tag activity received'); if(($item['owner_xchan'] === $u[0]['channel_hash']) && (! get_pconfig($u[0]['channel_id'],'system','blocktags'))) { + logger('tag_deliver: community tag recipient: ' . $u[0]['channel_name']); $j_tgt = json_decode_plus($item['target']); if($j_tgt && $j_tgt['id']) { $p = q("select * from item where mid = '%s' and uid = %d limit 1", diff --git a/include/text.php b/include/text.php index e3b1f1c4e..d549f206e 100755 --- a/include/text.php +++ b/include/text.php @@ -619,12 +619,28 @@ function get_tags($s) { } } + // make sure the longer tags are returned first so that if two or more have common substrings + // we'll replace the longest ones first. Otherwise the common substring would be found in + // both strings and the string replacement would link both to the shorter strings and + // fail to link the longer string. RedMatrix github issue #378 + + usort($ret,'tag_sort_length'); - // logger('get_tags: ' . print_r($ret,true)); + + //logger('get_tags: ' . print_r($ret,true)); return $ret; } +function tag_sort_length($a,$b) { + if(mb_strlen($a) == mb_strlen($b)) + return 0; + return((mb_strlen($b) < mb_strlen($a)) ? (-1) : 1); +} + + + + function strip_zids($s) { return preg_replace('/[\?&]zid=(.*?)(&|$)/ism','$2',$s); |