diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4bb99f737d..f491e45caf 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2064,7 +2064,7 @@ function get_context($text, $words, $length = 400) { if (preg_match('#(?:[^\w]|^)(' . str_replace('\*', '\w*?', preg_quote($word, '#')) . ')(?:[^\w]|$)#i', $text, $match)) { - $pos = strpos($text, $match[1]); + $pos = utf8_strpos($text, $match[1]); if ($pos !== false) { $word_indizes[] = $pos; diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index b5005d8ceb..b0d8198936 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -445,7 +445,7 @@ class bbcode_firstpass extends bbcode $code = preg_replace('#(?:[\n\r\s\t]| )*$#', '', $code); // remove newline at the end - if (!empty($code) && $code{utf8_strlen($code)-1} == "\n") + if (!empty($code) && $code{strlen($code)-1} == "\n") { $code = substr($code, 0, -1); } @@ -499,14 +499,15 @@ class bbcode_firstpass extends bbcode $tok = ']'; $out = '['; + // First character is [ $in = substr($in, 1); $list_end_tags = array(); do { $pos = strlen($in); - $tok_len = strlen($tok); - for ($i = 0; $i < $tok_len; ++$i) + + for ($i = 0, $tok_len = strlen($tok); $i < $tok_len; ++$i) { $tmp_pos = strpos($in, $tok{$i}); diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 342952db69..9cd4026c2c 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -7,9 +7,9 @@ * @license http://opensource.org/licenses/gpl-license.php GNU Public License * * @todo make sure the replacements are called correctly -* already done: strtolower, strtoupper, ucfirst, str_split, strrpos, strlen (hopefully!) +* already done: strtolower, strtoupper, ucfirst, str_split, strrpos, strlen (hopefully!), strpos * remaining: clean_username, htmlentities (no longer needed for internal data?), htmlspecialchars (using charset), html_entity_decode (own function to reverse htmlspecialchars and not htmlentities) -* substr, strpos, strspn, chr, ord +* substr, strspn, chr, ord */ /** @@ -192,13 +192,7 @@ if (extension_loaded('mbstring')) /** * UTF-8 aware alternative to strpos - * Find position of first occurrence of a string - * - * @author Harry Fuecks - * @param string haystack - * @param string needle - * @param integer offset in characters (from left) - * @return mixed integer position or FALSE on failure + * @ignore */ function utf8_strpos($str, $needle, $offset = null) {