this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/third_party/yaml: fix faulty decoding of hidden fields

Change-Id: Ib311a7c03caf08824bf16d16083940e80d5b6d18
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9841
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>

+11 -17
+2 -17
internal/third_party/yaml/decode.go
··· 12 12 "strconv" 13 13 "strings" 14 14 "time" 15 - "unicode" 16 15 17 16 "cuelang.org/go/cue/ast" 18 17 "cuelang.org/go/cue/literal" 19 18 "cuelang.org/go/cue/token" 19 + "cuelang.org/go/internal" 20 20 ) 21 21 22 22 const ( ··· 539 539 } 540 540 541 541 func (d *decoder) label(n *node) ast.Label { 542 - var tag string 543 - if n.tag == "" && !n.implicit { 544 - tag = yaml_STR_TAG 545 - } else { 546 - tag, _ = d.resolve(n) 547 - } 548 - if tag == yaml_STR_TAG { 549 - // TODO: improve 550 - for i, r := range n.value { 551 - if !unicode.In(r, unicode.L) && r != '_' { 552 - if i == 0 || !unicode.In(r, unicode.N) { 553 - goto stringLabel 554 - } 555 - } 556 - } 542 + if ast.IsValidIdent(n.value) && !internal.IsDefOrHidden(n.value) { 557 543 return d.ident(n, n.value) 558 544 } 559 - stringLabel: 560 545 return &ast.BasicLit{ 561 546 ValuePos: d.start(n), 562 547 Kind: token.STRING,
+9
internal/third_party/yaml/decode_test.go
··· 155 155 "english: null", 156 156 "english: null", 157 157 }, { 158 + "_foo: 1", 159 + `"_foo": 1`, 160 + }, { 161 + `"#foo": 1`, 162 + `"#foo": 1`, 163 + }, { 164 + "_#foo: 1", 165 + `"_#foo": 1`, 166 + }, { 158 167 "~: null key", 159 168 `"~": "null key"`, 160 169 }, {