goccy / go-yaml

YAML support for the Go language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please verify 0b*** binary content and fallback to string

aapelismith opened this issue · comments

Please verify 0b*** binary content and fallback to string

Code Example:

package main

import (
    "fmt"
    "github.com/goccy/go-yaml"
)

var data = `
image:
  pullPolicy: Always
  repository: gj-public-aws-harbor.zatech.com/devops/nginx-echo
  tag: 0b903334
`

func main() {
    result := make(map[string]interface{})
    err := yaml.Unmarshal([]byte(data), &result)
    if err != nil {
	    panic(err)
    }
    fmt.Printf("%+v\n", result)
}

Output:

map[image:map[pullPolicy:Always repository:gj-public-aws-harbor.zatech.com/devops/nginx-echo tag:0]]

tag should not be 0 !!!

Other yaml packages, such as sigs.k8s.io/yaml, deal with 0b*** binary numbers. If it is a correct binary number, it will be processed as a number, otherwise fallback to a string