[ZBX-21998] Zabbix 6 regexp: incorrect expression "6\.2" Created: 2022 Nov 29  Updated: 2022 Dec 08  Resolved: 2022 Dec 08

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F), Server (S)
Affects Version/s: 6.0.10, 6.2.4
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: MArk Assignee: Karlis Salins
Resolution: Duplicate Votes: 2
Labels: expression, find, functions, regex, regular
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Oracle Linux Server 8.7


Attachments: PNG File image-2022-11-29-12-10-03-171.png    
Issue Links:
Duplicate
duplicates ZBX-21898 Add escaping of backslashes in histor... Closed

 Description   

To my knowledge, this issue was first reported at this forum topic.

With the "find" function, when using a regular expression and trying to escape a dot (.) character, Zabbix displays an incorrect parameter error.

TEST EXAMPLE:

Zabbix Proxy version has the string "6.2.4".

If trying to create a calculated item with the following formula, Zabbix displays an invalid parameter error.

find(/zbxproxy/zabbix[version],,"regexp","^6\.2")
Cannot update item
Invalid parameter "/1/params": incorrect expression starting from "find(/zbxproxy/zabbix[version],,"regexp","^6\.2")".

The same happens when trying to create or update a trigger.

Cannot update trigger
Invalid parameter "/1/expression": incorrect expression starting from "find(/zbxproxy/zabbix[version],,"regexp","^6\.2")=0".​ 

Zabbix displays an incorrect expression if using the backslash escape character ({}) with either single or double quotes.

find(/APP Zabbix Proxy/zabbix[version],,"regexp","^6\.2")
find(/APP Zabbix Proxy/zabbix[version],,"regexp",'^6\.2')

A valid expression is accepted if using two backslashes, but the result is false (= 0) as the actual backslash character is escaped.

find(/APP Zabbix Proxy/zabbix[version],,"regexp","^6\\.2")

By removing the escape character ({}) the expression is accepted. Still, the the dot character is interpreted as "any character".

find(/APP Zabbix Proxy/zabbix[version],,"regexp","^6.2")

It also accepts brackets between the dot.

find(/APP Zabbix Proxy/zabbix[version],,"regexp",'^6[.]2')

Despite Zabbix invalid parameter, he simple regular expression ("^6\.2") is compatible with PCRE.

I've also tried messing with Zabbix DB to force the backslash character in the expression.

My test item has the following values in Zabbix DB.

mysql> select params from items where itemid=44280;
+--------------------------------------------------+
| params                                           |
+--------------------------------------------------+
| find(/zbxproxy/zabbix[version],,"regexp","^6.2") |
+--------------------------------------------------+

 

Updating the item "params" yelds an unsupported item.

mysql> update items set params='find(/zbxproxy/zabbix[version],,"regexp","^6\\.2")' where itemid=44280;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0 

mysql> select params from items where itemid=44280;
+---------------------------------------------------+
| params                                            |
+---------------------------------------------------+
| find(/zbxproxy/zabbix[version],,"regexp","^6\.2") |
+---------------------------------------------------+

Unfortunately, the Frontend displays the following error.

Cannot parse formula: invalid escape sequence in string starting with "\.2")"

 

I'm not sure this issue happens with other functions aswell.

It would be nice to escape the dot character. Sometimes it can come in handy.



 Comments   
Comment by MArk [ 2022 Dec 02 ]

After upgrading to 6.2.5, the issue is still present.

Generated at Sun Apr 27 07:40:35 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.