diff --git a/core/modules/search/search.module b/core/modules/search/search.module
old mode 100644
new mode 100755
index e731e4f..4d6f1be
--- 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
old mode 100644
new mode 100755
index f121abd..c61b264
--- a/core/modules/search/search.test
+++ b/core/modules/search/search.test
@@ -1585,6 +1585,15 @@ 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');
+
+    // See issue 987472: This rendered node contains a particular combination of  
+    // multibyte characters and HTML entities which trigger a bug in Drupal 7.0 - 7.9. 
+    // In those versions search_excerpt() returned an empty string due to a corrupted HTML entity.
+    // The source node contents that produces this $text is: 123456789 HTMLTest +123456789+&lsquo;  +&lsquo;  +&lsquo;  +&lsquo;  +12345678  &nbsp;&nbsp;  +&lsquo;  +&lsquo;  +&lsquo;   &lsquo
+    $text = base64_decode('PGRpdiBjbGFzcz0iZmllbGQgZmllbGQtbmFtZS1ib2R5IGZpZWxkLXR5cGUtdGV4dC13aXRoLXN1bW1hcnkgZmllbGQtbGFiZWwtaGlkZGVuIj48ZGl2IGNsYXNzPSJmaWVsZC1pdGVtcyI+PGRpdiBjbGFzcz0iZmllbGQtaXRlbSBldmVuIiBwcm9wZXJ0eT0iY29udGVudDplbmNvZGVkIj48cD4xMjM0NTY3ODkgSFRNTFRlc3QgKzEyMzQ1Njc4OSvigJggICvigJggICvigJggICvigJggICsxMjM0NTY3OCAgwqDCoCAgK+KAmCAgK+KAmCAgK+KAmCAgIOKAmDwvcD4KPC9kaXY+PC9kaXY+PC9kaXY+IA==');
+    $expected = ' 123456789 <strong>HTMLTest</strong> +123456789+‘ +‘ +‘ +‘ +12345678    +‘ +‘ +‘ ...';
+    $result = preg_replace('| +|', ' ', search_excerpt('HTMLTest', $text));
+    $this->assertEqual($result, $expected, 'HTML encodings are not corrupted in search excerpts containing multibyte characters.');
   }
 
   /**
