diff -u b/core/modules/search/search.module b/core/modules/search/search.module --- b/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -831,8 +831,8 @@ $new_key = Unicode::strtolower($temp); $new_key = \Drupal::service('transliteration')->removeDiacritics($new_key); if (preg_match('/' . $boundary . preg_quote($new_key, '/') . $boundary . '/iu', ' ' . $new_text . ' ')) { - $position = strpos($new_text, $new_key); - return substr($text, $position, strlen($new_key)); + $position = Unicode::strpos($new_text, $new_key); + return Unicode::substr($text, $position, Unicode::strlen($new_key)); } // Run both text and key through search_simplify. only in patch2: unchanged: --- a/core/lib/Drupal/Component/Utility/Unicode.php +++ b/core/lib/Drupal/Component/Utility/Unicode.php @@ -697,4 +697,29 @@ public static function validateUtf8($text) { return (preg_match('/^./us', $text) == 1); } + /** + * Finds the position of the first occurrence of a string in another string. + * + * @param string $haystack + * The string to search in. + * @param string $needle + * The string to find in $haystack. + * @param int $offset + * If specified, start the search at this number of characters from the + * beginning (default 0). + * + * @return int|false + * The position where $needle occurs in $haystack, always relative to the + * beginning (independent of $offset), or FALSE if not found. Note that + * a return value of 0 is not the same as FALSE. + */ + public static function strpos($haystack, $needle, $offset = 0) { + if (static::getStatus() == static::STATUS_MULTIBYTE) { + return mb_strpos($haystack, $needle, $offset); + } + else { + return strpos($haystack, $needle, $offset); + } + } + }