Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions encoding/yaml/yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func TestYAMLValues(t *testing.T) {
{`"-.Inf"`, `"-.Inf"`},
{`"2002"`, `"2002"`},
{`"685_230.15"`, `"685_230.15"`},
{`"0x123456789012345678901234567890"`, `"0x123456789012345678901234567890"`},

// Legacy values.format.
{`"no"`, `"no"`},
Expand Down
2 changes: 1 addition & 1 deletion internal/encoding/yaml/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func shouldQuote(str string) bool {

// This regular expression conservatively matches any date, time string,
// or base60 float.
var useQuote = regexp.MustCompile(`^[\-+0-9:\. \t]+([-:]|[tT])[\-+0-9:\. \t]+[zZ]?$`)
var useQuote = regexp.MustCompile(`^[\-+0-9:\. \t]+([-:]|[tT])[\-+0-9:\. \t]+[zZ]?$|^0x[a-fA-F0-9]+$`)

// legacyStrings contains a map of fixed strings with special meaning for any
// type in the YAML Tag registry (https://yaml.org/type/index.html) as used
Expand Down
4 changes: 4 additions & 0 deletions internal/encoding/yaml/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func TestEncodeFile(t *testing.T) {
in: `
package test

bighex: "0x1234567890123456789001234567890"
nothex: "0x1234567890123456789001234567890zz"
seq: [
1, 2, 3, {
a: 1
Expand All @@ -50,6 +52,8 @@ func TestEncodeFile(t *testing.T) {
}
`,
out: `
bighex: "0x1234567890123456789001234567890"
nothex: 0x1234567890123456789001234567890zz
seq:
- 1
- 2
Expand Down