Skip to content

Commit

Permalink
ObjectSuggestions: Fix exotic columns match
Browse files Browse the repository at this point in the history
These columns should only be displayed if the full column name is explicitly specified by the user.
   For example: `name_checksum` should show matches, but (`name|checksum|_checksum|ame_checksum`) should not.
Previously, exotic columns were also suggested, even if only the column name suffix matched
  • Loading branch information
sukhwinder33445 committed Nov 27, 2024
1 parent 4806939 commit 379089a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,9 @@ protected function fetchColumnSuggestions($searchTerm)

protected function matchSuggestion($path, $label, $searchTerm)
{
if (preg_match('/[_.](id|bin|checksum)$/', $path)) {
// Only suggest exotic columns if the user knows about them
$trimmedSearch = trim($searchTerm, ' *');
return substr($path, -strlen($trimmedSearch)) === $trimmedSearch;
if (preg_match('/[_.](id|bin|checksum)$/', $path, $matches)) {
// Only suggest exotic columns if the user knows the full column path
return substr($path, strrpos($path, '.') + 1) === trim($searchTerm, ' *');
}

return parent::matchSuggestion($path, $label, $searchTerm);
Expand Down

0 comments on commit 379089a

Please sign in to comment.