diff --git a/.craftplugin b/.craftplugin index d16f3f7..0f0ac72 100644 --- a/.craftplugin +++ b/.craftplugin @@ -1 +1 @@ -{"pluginName":"Extended Search","pluginDescription":"Retrieve additional context for Element searches","pluginVersion":"0.0.2","pluginAuthorName":"Studentenwerk OstNiedersachsen","pluginVendorName":"Studentenwerk OstNiedersachsen","pluginAuthorUrl":"https://stw-on.de","pluginAuthorGithub":"stw-on","codeComments":"yes","pluginComponents":["models","services","variables"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"} \ No newline at end of file +{"pluginName":"Extended Search","pluginDescription":"Retrieve additional context for Element searches","pluginVersion":"0.0.3","pluginAuthorName":"Studentenwerk OstNiedersachsen","pluginVendorName":"Studentenwerk OstNiedersachsen","pluginAuthorUrl":"https://stw-on.de","pluginAuthorGithub":"stw-on","codeComments":"yes","pluginComponents":["models","services","variables"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"} \ No newline at end of file diff --git a/composer.json b/composer.json index 47277ac..7454518 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "stw-on/craft-extended-search", "description": "Retrieve additional context for Element searches", "type": "craft-plugin", - "version": "2.0.0", + "version": "2.0.1", "keywords": [ "craft", "cms", diff --git a/src/services/ExtendedSearchService.php b/src/services/ExtendedSearchService.php index afa48a6..30721a9 100644 --- a/src/services/ExtendedSearchService.php +++ b/src/services/ExtendedSearchService.php @@ -144,7 +144,7 @@ protected function getNormalizedValue($value) protected function contextualizeHit($content, $term, $length) { $content = strip_tags($content); - $pattern = '/(' . $term . ')/im'; + $pattern = '/(' . preg_quote($term) . ')/im'; $midway = round($length / 2); if (strlen($content) > $length) { // if the hit is after the middle, we need to shorten the text on both sides