Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-10929

Can't use unicode in LLD JSON string

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Duplicate
    • Icon: Trivial Trivial
    • None
    • 3.0.2
    • Proxy (P), Server (S)
    • CentOS 6.7

      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.

        1. zbx_unicode_bug_host.xml
          5 kB
          Fernando Schmitt
        2. zbx_unicode_bug_items.png
          34 kB
          Fernando Schmitt
        3. zbx_unicode_bug_lld.png
          25 kB
          Fernando Schmitt
        4. zbx_unicode_bug_test.sh
          0.1 kB
          Fernando Schmitt

            Unassigned Unassigned
            fernandosch Fernando Schmitt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: