From 334aa4029216fc1d64958d2f23731ef5d34027fa Mon Sep 17 00:00:00 2001 From: Pascal Deklerck Date: Sun, 27 May 2018 10:11:51 +0200 Subject: [PATCH] Fix autoname output length --- include/text.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/text.php b/include/text.php index 3f66d379c9..6e2fb33bba 100644 --- a/include/text.php +++ b/include/text.php @@ -151,7 +151,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 +177,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; } -- 2.39.5