Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: decode !!binary as []byte #1039

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ func (d *decoder) scalar(n *Node, out reflect.Value) bool {
if err != nil {
failf("!!binary value contains invalid base64 data")
}
resolved = string(data)
resolved = data
}
}
if resolved == nil {
Expand Down
8 changes: 4 additions & 4 deletions decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"time"

. "gopkg.in/check.v1"
"gopkg.in/yaml.v3"
"github.com/setrofim/yaml"
)

var unmarshalIntTest = 123
Expand Down Expand Up @@ -633,13 +633,13 @@ var unmarshalTests = []struct {
// Binary data.
{
"a: !!binary gIGC\n",
map[string]string{"a": "\x80\x81\x82"},
map[string][]byte{"a": []byte{0x80, 0x81, 0x82}},
}, {
"a: !!binary |\n " + strings.Repeat("kJCQ", 17) + "kJ\n CQ\n",
map[string]string{"a": strings.Repeat("\x90", 54)},
map[string][]byte{"a": bytes.Repeat([]byte{0x90}, 54)},
}, {
"a: !!binary |\n " + strings.Repeat("A", 70) + "\n ==\n",
map[string]string{"a": strings.Repeat("\x00", 52)},
map[string][]byte{"a": bytes.Repeat([]byte{0x00}, 52)},
},

// Issue #39.
Expand Down
2 changes: 1 addition & 1 deletion encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"os"

. "gopkg.in/check.v1"
"gopkg.in/yaml.v3"
"github.com/setrofim/yaml"
)

var marshalIntTest = 123
Expand Down
2 changes: 1 addition & 1 deletion example_embedded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"fmt"
"log"

"gopkg.in/yaml.v3"
"github.com/setrofim/yaml"
)

// An example showing how to unmarshal embedded
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "gopkg.in/yaml.v3"
module github.com/setrofim/yaml

require (
"gopkg.in/check.v1" v0.0.0-20161208181325-20d25e280405
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
)
2 changes: 1 addition & 1 deletion limit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

. "gopkg.in/check.v1"
"gopkg.in/yaml.v3"
"github.com/setrofim/yaml"
)

var limitTests = []struct {
Expand Down
12 changes: 2 additions & 10 deletions node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"os"

. "gopkg.in/check.v1"
"gopkg.in/yaml.v3"
"github.com/setrofim/yaml"
"io"
"strings"
)
Expand Down Expand Up @@ -2689,15 +2689,7 @@ var setStringTests = []struct {
Tag: "!!str",
Style: yaml.LiteralStyle,
},
}, {
"\x80\x81\x82",
"!!binary gIGC\n",
yaml.Node{
Kind: yaml.ScalarNode,
Value: "gIGC",
Tag: "!!binary",
},
},
},
}

func (s *S) TestSetString(c *C) {
Expand Down