Skip to content

Commit

Permalink
fixed preg_quote bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Aug 9, 2023
1 parent 2746ca3 commit 2531015
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/).

## 1.4.2 (25. January 2022)
## 1.4.3 (9. August 2023)

+ Fixed bug with wrong quoted regex in StringHelper::highlightWord() method.

## 1.4.2 (25. January 2023)

+ [#16](https://github.com/luyadev/yii-helpers/pull/16) Fix PHP 8.1 compatibility bug in `ExportHelper::xlsx()`.

## 1.4.1 (18. January 2022)
## 1.4.1 (18. January 2023)

+ [#15](https://github.com/luyadev/yii-helpers/pull/15) Fix PHP 8.1 compatibility bug in `ArrayHelper::searchColumns()`.

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public static function highlightWord($content, $word, $markup = '<b>%s</b>')
// otherwise this can generate wrong highlight results like a highlight inside of a highlight.
if (count($words) > 1) {
foreach ($words as $wordIndex => $word) {
$inArrayIndex = preg_grep('/'.preg_quote($word).'/', $words);
$inArrayIndex = preg_grep('/'.preg_quote($word, '/').'/', $words);
if ((is_countable($inArrayIndex) ? count($inArrayIndex) : 0) > 1) {
unset($words[$wordIndex]);
}
Expand Down

0 comments on commit 2531015

Please sign in to comment.