mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 23:34:08 +02:00
Detect exact names during autocompletion
Do not recognize substrings of strings as the full string in searchMatch. fixes #9633
This commit is contained in:
parent
a0b559f032
commit
2d9d3a0788
@ -273,30 +273,10 @@ class Loader
|
|||||||
|
|
||||||
protected function searchMatch($needle, $haystack)
|
protected function searchMatch($needle, $haystack)
|
||||||
{
|
{
|
||||||
$stack = $haystack;
|
$this->lastSuggestions = preg_grep(sprintf('/^%s.*$/', preg_quote($needle, '/')), $haystack);
|
||||||
$search = $needle;
|
$match = array_search($needle, $haystack, true);
|
||||||
$this->lastSuggestions = array();
|
if (false !== $match) {
|
||||||
while (strlen($search) > 0) {
|
return $haystack[$match];
|
||||||
$len = strlen($search);
|
|
||||||
foreach ($stack as & $s) {
|
|
||||||
$s = substr($s, 0, $len);
|
|
||||||
}
|
|
||||||
|
|
||||||
$res = array_keys($stack, $search, true);
|
|
||||||
if (count($res) === 1) {
|
|
||||||
$found = $haystack[$res[0]];
|
|
||||||
if (substr($found, 0, strlen($needle)) === $needle) {
|
|
||||||
return $found;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} elseif (count($res) > 1) {
|
|
||||||
foreach ($res as $key) {
|
|
||||||
$this->lastSuggestions[] = $haystack[$key];
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$search = substr($search, 0, -1);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user