Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes the issue of apostrophes in an article titles causing the title to be truncated in search results. 
Resolves joomla-extensions#7 (joomla-extensions#7)
Resolves joomla/joomla-cms#34724 (joomla/joomla-cms#34724)
Work around is to not run titles through search preparation which truncates text around the search term. Titles are returned in full instead - which is the expected behavior for search results (a user wants to see the title of an article not an extract of the title).
  • Loading branch information
zzella authored Apr 4, 2022
1 parent cf446e7 commit f11bd86
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/com_search/views/search/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function display($tpl = null)
for ($i = 0, $count = count($results); $i < $count; ++$i)
{
$rowTitle = &$results[$i]->title;
$rowTitleHighLighted = $this->highLight($rowTitle, $needle, $searchWords);
$rowTitleHighLighted = $this->highLight($rowTitle, $needle, $searchWords, false);
$rowText = &$results[$i]->text;
$rowTextHighLighted = $this->highLight($rowText, $needle, $searchWords);

Expand Down Expand Up @@ -206,7 +206,7 @@ public function display($tpl = null)
*
* @since 3.8.4
*/
public function highLight($string, $needle, $searchWords)
public function highLight($string, $needle, $searchWords, $prepare=true)
{
$hl1 = '<span class="highlight">';
$hl2 = '</span>';
Expand All @@ -216,7 +216,9 @@ public function highLight($string, $needle, $searchWords)
// Doing HTML entity decoding here, just in case we get any HTML entities here.
$quoteStyle = version_compare(PHP_VERSION, '5.4', '>=') ? ENT_NOQUOTES | ENT_HTML401 : ENT_NOQUOTES;
$row = html_entity_decode($string, $quoteStyle, 'UTF-8');
$row = SearchHelper::prepareSearchContent($row, $needle);
if($prepare) {
$row = SearchHelper::prepareSearchContent($row, $needle);
}
$searchWords = array_values(array_unique($searchWords));
$lowerCaseRow = $mbString ? mb_strtolower($row) : StringHelper::strtolower($row);

Expand Down

0 comments on commit f11bd86

Please sign in to comment.