fix: correctly sanitize comments out of the jsonc content
This commit is contained in:
1 file changed
+8
-2
@@ -1,13 +1,14 @@
|
|||||||
package appjson
|
package appjson
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/dokku/dokku/plugins/common"
|
"github.com/dokku/dokku/plugins/common"
|
||||||
json "github.com/marcozac/go-jsonc"
|
"github.com/marcozac/go-jsonc"
|
||||||
"k8s.io/utils/ptr"
|
"k8s.io/utils/ptr"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -262,8 +263,13 @@ func ReadAppJSON(path string) (AppJSON, error) {
|
|||||||
return AppJSON{}, nil
|
return AppJSON{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data, err := jsonc.Sanitize(b)
|
||||||
|
if err != nil {
|
||||||
|
return AppJSON{}, fmt.Errorf("Cannot sanitize app.json: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
var appJSON AppJSON
|
var appJSON AppJSON
|
||||||
if err = json.Unmarshal(b, &appJSON); err != nil {
|
if err = json.Unmarshal(data, &appJSON); err != nil {
|
||||||
return AppJSON{}, fmt.Errorf("Cannot parse app.json: %v", err)
|
return AppJSON{}, fmt.Errorf("Cannot parse app.json: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user