From 87a1fbc1f6875196d0347cc2b6565f4e730d384a Mon Sep 17 00:00:00 2001 From: webchick Date: Wed, 11 Jan 2012 23:16:22 -0500 Subject: Issue #987472 by damien_vancouver, OnkelTem: Fixed search.module doesn't consistently support multibyte characters. --- modules/search/search.module | 2 +- modules/search/search.test | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'modules/search') diff --git a/modules/search/search.module b/modules/search/search.module index 518272a02..915c96fb2 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -1188,7 +1188,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/modules/search/search.test b/modules/search/search.test index 38bb0a74c..ca1dd24a3 100644 --- a/modules/search/search.test +++ b/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 = "

123456789 HTMLTest +123456789+‘ +‘ +‘ +‘ +12345678    +‘ +‘ +‘ ‘

\n
"; + $result = search_excerpt('HTMLTest', $text); + $this->assertFalse(empty($result), 'Rendered Multi-byte HTML encodings are not corrupted in search excerpts'); } /** -- cgit v1.2.3