// parseUnquotedParam parses item key normal parameter (any combination of any characters except ',' and ']',
** Copyright (C) 2001-2023 Zabbix SIA
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
** 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 General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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")