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

backslash is not escaped in API response (at least in event.get and trigger.get)

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Won't fix
    • Icon: Major Major
    • None
    • 2.4.5, 3.0.0alpha5
    • API (A)

      \ is not escaped in API response with another \

      But it should be as JSON spec suggests:
      http://www.json.org/
      http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf

      Not escaping backslash means that Zabbix would returns invalid JSON object.

      How to reproduce
      1. Put a backslash inside a trigger's description in Zabbix somewhere. To make it more meanful, it could be a Windows performance counter's description:

      \?????????? ????(_Total)\% ?????????? ????? - ??? ?? ????? ???????, ????? ??????? ???? ??????? ?? ??????? ????? ?????????? ???????????.
      

      2. Now grab triggers with API:

      {
          "jsonrpc": "2.0",
          "method": "trigger.get",
          "params": {
              "output": "extend",
              "filter": {"triggerid":13096}
          },
          "auth": "ab092dc5a9436b548db72cec71287eae",
          "id": 1
      }
      

      you will get an object:

      {
        "jsonrpc": "2.0",
        "result": [
          {
            "triggerid": "13096",
              "expression": "({880099}>80)and({880100}=0)",
              "description": "[PERF.HDD] ??????? ???? ??????? ?????? ????????: {ITEM.LASTVALUE}%",
            "url": "",
            "status": "0",
            "value": "0",
            "priority": "3",
            "lastchange": "0",
            "comments": "\?????????? ????(_Total)\% ?????????? ????? - ??? ?? ????? ???????, ????? ??????? ???? ??????? ?? ??????? ????? ?????????? ???????????.",
            "error": "",
            "templateid": "0",
            "type": "0",
            "state": "0",
            "flags": "0"
          }
        ],
        "id": 1
      }
      

      That is not a valid JSON object because \ is not escaped with another backslash inside the string comments . Can be double checked by pasting it to https://jsonformatter.curiousconcept.com

      Checked on 2.4.2 and 3.0 alpha5

            Unassigned Unassigned
            vzhuravlev Vitaly Zhuravlev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: