Skip to content

Commit

Permalink
Fix search terms containing regex characters
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschwarzer committed Oct 19, 2020
1 parent 045c299 commit 6db3b4b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .craftplugin
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/services/ExtendedSearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6db3b4b

Please sign in to comment.