]> git.mxchange.org Git - friendica.git/commitdiff
catch a couple of edge cases with the tag linkifier
authorMike Macgirvin <mike@macgirvin.com>
Fri, 29 Oct 2010 03:11:50 +0000 (20:11 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Fri, 29 Oct 2010 03:11:50 +0000 (20:11 -0700)
boot.php
mod/item.php

index 870a4c33b7f55276e9315eac5a99af2728a520b2..f69d66be55cfda400527fa01696dd50e80f8d0cb 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -1298,10 +1298,18 @@ function activity_match($haystack,$needle) {
 }}
 
 
+// Pull out all #hashtags and @person tags from $s;
+// We also get @person@domain.com - which would make 
+// the regex quite complicated as tags can also
+// end a sentence. So we'll run through our results
+// and strip the period from any tags which end with one.
+// Returns array of tags found, or empty array.
+
+
 if(! function_exists('get_tags')) {
 function get_tags($s) {
        $ret = array();
-       if(preg_match_all('/([@#][^ ,:?]*)[ ,:?]/',$s,$match)) {
+       if(preg_match_all('/([@#][^ ,:?]*)([ ,:?]|$)/',$s,$match)) {
                foreach($match[1] as $match) {
                        if(substr($match,-1,1) === '.')
                                $ret[] = substr($match,0,-1);
@@ -1314,6 +1322,8 @@ function get_tags($s) {
 }}
 
 
+// quick and dirty quoted_printable encoding
+
 if(! function_exists('qp')) {
 function qp($s) {
 return str_replace ("%","=",rawurlencode($s));
index 64a23e7fb1ad6f1f8ff8a8ce92018317cbf60228..126f8b6a1a8ce6a893ac3f586febbc4f2a4813b1 100644 (file)
@@ -147,10 +147,10 @@ function item_post(&$a) {
                                        }
                                }
                                if($profile) {
-                                       $profile = str_replace(',','%2c',$profile);
                                        $body = str_replace($name,'[url=' . $profile . ']' . $name      . '[/url]', $body);
                                        if(strlen($str_tags))
                                                $str_tags .= ',';
+                                       $profile = str_replace(',','%2c',$profile);
                                        $str_tags .= '[url=' . $profile . ']' . $name   . '[/url]';
                                }
                        }