Skip to content

Commit

Permalink
Use regexp with word boundaries for more reliable replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
vlakoff committed Sep 25, 2021
1 parent 1e333e6 commit d2aa2df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions system/Database/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public function debugToolbarDisplay(): string
'INTO',
'VALUES',
'UPDATE',
'OR ',
'OR',
'HAVING',
'OFFSET',
'NOT IN',
Expand All @@ -407,9 +407,9 @@ public function debugToolbarDisplay(): string
$sql = $this->finalQueryString;

foreach ($highlight as $term) {
$from = $term;
$to = '<strong>' . str_replace(' ', '&nbsp;', $term) . '</strong>';
$sql = str_replace($from, $to, $sql);
$sql = preg_replace_callback('/\b' . preg_quote($term, '/') . '\b/', function ($matches) {
return '<strong>' . str_replace(' ', '&nbsp;', $matches[0]) . '</strong>';
}, $sql);
}

return $sql;
Expand Down

0 comments on commit d2aa2df

Please sign in to comment.