Source
if ('\0' != *(str += len) && 0 != (flags & ZBX_FLAG_DOUBLE_SUFFIX) && NULL != strchr(ZBX_UNIT_SYMBOLS, *str))
/*
** 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/>.
**/
/******************************************************************************
* *
* Return value: SUCCEED - char is allowed in item key *
* FAIL - otherwise *
* *
* Comments: allowed characters in key are: '0-9a-zA-Z._-' *
* !!! Don't forget to sync the code with PHP !!! *
* *
******************************************************************************/
int zbx_is_key_char(unsigned char c)
{
if (0 != isalnum(c))
return SUCCEED;
if (c == '.' || c == '_' || c == '-')
return SUCCEED;
return FAIL;
}
/******************************************************************************
* *
* Purpose: Advances pointer to first invalid character in string *
* ensuring that everything before it is a valid key. *
* *
* e.g., system.run[cat /etc/passwd | awk -F: '{ print $1 }'] *
* *
* Parameters: exp - [IN/OUT] pointer to first char of key *
* *
* e.g., {host:system.run[cat /etc/passwd | awk -F: '{ print $1 }'].last(0)} *
* ^ *
* Return value: Returns FAIL only if no key is present (length 0), *
* or the whole string is invalid. SUCCEED otherwise. *
* *
* Comments: The pointer is advanced to the first invalid character even if *
* FAIL is returned (meaning there is a syntax error in item key). *
* If necessary, the caller must keep a copy of pointer original *
* value. *
* *
******************************************************************************/
int zbx_parse_key(const char **exp)
{
const char *s;