[ZBX-10929] Can't use unicode in LLD JSON string Created: 2016 Jun 21  Updated: 2017 May 30  Resolved: 2016 Jun 27

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P), Server (S)
Affects Version/s: 3.0.2
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: Fernando Schmitt Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: json, lld, unicode, utf8
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

CentOS 6.7


Attachments: XML File zbx_unicode_bug_host.xml     PNG File zbx_unicode_bug_items.png     PNG File zbx_unicode_bug_lld.png     File zbx_unicode_bug_test.sh    
Issue Links:
Duplicate
duplicates ZBX-10540 Japanese characters are changed to ??... Closed

 Description   

Create a external check script to mimick a LLD with non-ascii characters 'çã', using 3 methods:

1. UTF-8 encoded unicode: 0xc3 0xa7 0xc3 0xa3
2. ISO-8859-1 encoded: 0xe7 0xe3
3. JSON unicode escaped: "\u00e7\u00e3"

This can be achieved with the following code:
test.sh:

#!/bin/bash
echo '{"data":[{"{#IFNAME}":"çã"},{"{#IFNAME}":"'"$(echo 'çã' | iconv -t iso88591)"'"},{"{#IFNAME}":"\u00e7\u00e3"}]}'

Note that the script assumes your environment to be UTF-8.

Now create a LLD rule and use the external script as key (check xml host example). Zabbix will do the following:

1. UTF-8 byte sequence will be interpreted as ISO-8859-1 and get doubly encoded to 0xc3 0x83 0xc2 0xa7 0xc3 0x83 0xc2 0xa3 (çã)
2. ISO-8859-1 bytes will be replaced with '?' by function 'zbx_replace_invalid_utf8' in 'src/libs/zbxcommon/str.c'.
3. Non-control characters escaped in JSON notation will cause the LLD rule to fail (because function 'zbx_json_decode_character' in 'src/libs/zbxjson/json.c' does not support such characters).

Please check the screenshots.



 Comments   
Comment by Fernando Schmitt [ 2016 Jun 22 ]

If the script is used as a normal item (instead of a LLD rule), there is no double-encoding issue:

TIMESTAMP              VALUE
2016-06-21 19:13:38    {"data":[{"{#IFNAME}":"çã"},{"{#IFNAME}":"??"},{"{#IFNAME}":"\u00e7\u00e3"}]}
Comment by Aleksandrs Saveljevs [ 2016 Jun 22 ]

The çã entry seems to work well for me - the LLD item is correctly created with item key xxx[çã].

Could you please try upgrading to Zabbix 3.0.3 and check whether this issue could be a duplicate of ZBX-10540?

Comment by Aleksandrs Saveljevs [ 2016 Jun 22 ]

By the way, thank you for a quality report, a detailed description, and useful attachments!

Comment by Fernando Schmitt [ 2016 Jun 22 ]

yes, it is solved in 3.0.3! thanks!

Comment by Aleksandrs Saveljevs [ 2016 Jun 27 ]

Thank you! Closing as a duplicate of ZBX-10540.

Generated at Tue May 20 07:49:30 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.