X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fstrings.php;h=e9bac3f31b7cf5a15e41f10bc2627bfdb638060f;hp=4481bd6ba5643f53cff2b3dafc25b5cb973084dc;hb=ff4f08ffa2021f515fc7ec4c4b261d3a4738e68e;hpb=88cb1b4d2ebd3e74fcee1d756df4e420da8bdf09 diff --git a/functions/strings.php b/functions/strings.php index 4481bd6b..e9bac3f3 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -209,8 +209,9 @@ function translateText(&$body, $wrap_at, $charset) { $Quotes = 0; $pos = 0; + $j = strlen( $line ); - while ( $line <> '' ) { + while ( $pos < $j ) { if ($line[$pos] == ' ') { $pos ++; } else if (strpos($line, '>', $pos) === $pos) { @@ -538,14 +539,15 @@ function GenerateRandomString($size, $chars, $flags = 0) { if (($size < 1) || (strlen($chars) < 1)) { return ''; } - + sq_mt_randomize(); /* Initialize the random number generator */ - + $String = ''; + $j = strlen( $chars ) - 1; while (strlen($String) < $size) { - $String .= $chars[mt_rand(0, strlen($chars))]; + $String .= $chars{mt_rand(0, $j)}; } - + return $String; }