]> git.mxchange.org Git - friendica.git/blobdiff - include/text.php
Merge branch 'master' into develop
[friendica.git] / include / text.php
index 3f66d379c9666e2f5162fccf60ca21ef070199fa..53eae1ff33924f7118df4c5f8beb3714743628c0 100644 (file)
@@ -14,6 +14,7 @@ use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
+use Friendica\Model\Contact;
 use Friendica\Model\Event;
 use Friendica\Model\Item;
 use Friendica\Model\Profile;
@@ -151,7 +152,7 @@ function autoname($len) {
                                'nd','ng','nk','nt','rn','rp','rt'];
 
        $noend = ['bl', 'br', 'cl','cr','dr','fl','fr','gl','gr',
-                               'kh', 'kl','kr','mn','pl','pr','rh','tr','qu','wh'];
+                               'kh', 'kl','kr','mn','pl','pr','rh','tr','qu','wh','q'];
 
        $start = mt_rand(0,2);
        if ($start == 0) {
@@ -177,15 +178,13 @@ function autoname($len) {
        $word = substr($word,0,$len);
 
        foreach ($noend as $noe) {
-               if ((strlen($word) > 2) && (substr($word, -2) == $noe)) {
-                       $word = substr($word, 0, -1);
+               $noelen = strlen($noe);
+               if ((strlen($word) > $noelen) && (substr($word, -$noelen) == $noe)) {
+                       $word = autoname($len);
                        break;
                }
        }
 
-       if (substr($word, -1) == 'q') {
-               $word = substr($word, 0, -1);
-       }
        return $word;
 }
 
@@ -1968,6 +1967,10 @@ function undo_post_tagging($s) {
        $cnt = preg_match_all('/([!#@])\[url=(.*?)\](.*?)\[\/url\]/ism', $s, $matches, PREG_SET_ORDER);
        if ($cnt) {
                foreach ($matches as $mtch) {
+                       if (in_array($mtch[1], ['!', '@'])) {
+                               $contact = Contact::getDetailsByURL($mtch[2]);
+                               $mtch[3] = empty($contact['addr']) ? $mtch[2] : $contact['addr'];
+                       }
                        $s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s);
                }
        }