• juanvallejo's avatar
    Prevent json decoder panic on invalid input · 07ca2198
    juanvallejo authored
    This patch handles cases where `ioutil.ReadAll` will return a single
    character output on an invalid json input, causing the `Decode` method
    to panic when it tries to calculate the line number for the syntax
    error. The example below would cause a panic due to the trailing comma
    at the end:
    
    ```
    {
      "kind": "Pod",
      "apiVersion": "v1",
      "metadata": {
        "name": "",
        "labels": {
          "name": ""
        },
        "generateName": "",
        "namespace": "",
        "annotations": []
      },
      "spec": {}
    },
    ```
    07ca2198
json.go 7.36 KB