** Copyright (C) 2001-2025 Zabbix SIA
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
func isKeyChar(c byte, wildcard bool) bool {
if c >= 'a' && c <= 'z' {
if c == '.' || c == '-' || c == '_' {
if c >= '0' && c <= '9' {
if c >= 'A' && c <= 'Z' {
if wildcard && c == '*' {
// parseQuotedParam parses item key quoted parameter "..." and returns
// the parsed parameter (including quotes, but without whitespace outside quotes)
// and the data after the parameter (skipping also whitespace after closing quotes).
func parseQuotedParam(data []byte) (param []byte, left []byte, err error) {
for i, c := range data[1:] {
if c == '"' && last != '\\' {
for ; i < len(data) && data[i] == ' '; i++ {
err = errors.New("unterminated quoted string")
// parseUnquotedParam parses item key normal parameter (any combination of any characters except ',' and ']',
// including trailing whitespace) and returns the parsed parameter and the data after the parameter.