diff --git a/core/modules/search/search.module b/core/modules/search/search.module index e731e4f2dc44d4e49bf635735c2e792bdb54c1e5..4d6f1be780b185497256466aa4f43a469b750639 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -1165,7 +1165,7 @@ function search_excerpt($keys, $text) { if (($s = strrpos($end, ' ')) !== FALSE) { // Account for the added spaces. $q = max($q - 1, 0); - $s = min($s, drupal_strlen($end) - 1); + $s = min($s, strlen($end) - 1); $ranges[$q] = $p + $s; $length += $p + $s - $q; $included[$key] = $p + 1; diff --git a/core/modules/search/search.test b/core/modules/search/search.test index 6909efd66754f09e655d4e77f8766faa18f9e3df..1ee4e6ff8e5942160085310d7fae2a664b17878e 100644 --- a/core/modules/search/search.test +++ b/core/modules/search/search.test @@ -1599,6 +1599,12 @@ class SearchExcerptTestCase extends DrupalUnitTestCase { $result = preg_replace('| +|', ' ', search_excerpt('nothing', $entities)); $this->assertFalse(strpos($result, '&'), 'Entities are not present in excerpt'); $this->assertTrue(strpos($result, 'Ã') > 0, 'Entities are converted in excerpt'); + + // The node body that will produce this rendered $text is: + // 123456789 HTMLTest +123456789+‘ +‘ +‘ +‘ +12345678 +‘ +‘ +‘ ‘ + $text = "<div class=\"field field-name-body field-type-text-with-summary field-label-hidden\"><div class=\"field-items\"><div class=\"field-item even\" property=\"content:encoded\"><p>123456789 HTMLTest +123456789+‘ +‘ +‘ +‘ +12345678   +‘ +‘ +‘ ‘</p>\n</div></div></div> "; + $result = search_excerpt('HTMLTest', $text); + $this->assertFalse(empty($result), 'Rendered Multi-byte HTML encodings are not corrupted in search excerpts'); } /**