From d2aa2dff8d6e159c3f6ffe244b5807009bf8b59a Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sat, 25 Sep 2021 05:43:59 +0200 Subject: [PATCH] Use regexp with word boundaries for more reliable replacements --- system/Database/Query.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/Database/Query.php b/system/Database/Query.php index 0dffb86ccf0e..251ed5ec05d2 100644 --- a/system/Database/Query.php +++ b/system/Database/Query.php @@ -382,7 +382,7 @@ public function debugToolbarDisplay(): string 'INTO', 'VALUES', 'UPDATE', - 'OR ', + 'OR', 'HAVING', 'OFFSET', 'NOT IN', @@ -407,9 +407,9 @@ public function debugToolbarDisplay(): string $sql = $this->finalQueryString; foreach ($highlight as $term) { - $from = $term; - $to = '' . str_replace(' ', ' ', $term) . ''; - $sql = str_replace($from, $to, $sql); + $sql = preg_replace_callback('/\b' . preg_quote($term, '/') . '\b/', function ($matches) { + return '' . str_replace(' ', ' ', $matches[0]) . ''; + }, $sql); } return $sql;