Skip to content

Commit

Permalink
Merge pull request #137 from Shopify/epk/update
Browse files Browse the repository at this point in the history
Release `1.5.0`
  • Loading branch information
epk authored Feb 26, 2024
2 parents 5ec268c + b8b49d4 commit 4719b8c
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/dockerfile-for-dependabot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Used for dependabot to detect new golang versions
FROM golang:1.20.5-alpine
FROM golang:1.21.4-alpine
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: goreleaser/goreleaser-action@5df302e5e9e4c66310a6b6493a8865b12c555af2
with:
distribution: goreleaser
version: v1.18.1
version: v1.22.1
args: release --clean --release-notes=tmp/release_changelog.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# .goreleaser.yaml
builds:
- main: ./cmd/ejson/
flags:
- -trimpath
ldflags:
- -s -w -extldflags "-static"
env:
- CGO_ENABLED=0
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.5.0

* Bump Go version and update dependencies
* Build static binaries

# 1.3.2

* Bump Go version and update dependencies
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ build/man/%.gz: man/%.ronn
set -euo pipefail ; $(BUNDLE_EXEC) ronn -r --pipe "$<" | gzip > "$@" || (rm -f "$<" ; false)

build/bin/linux-amd64: $(GOFILES) cmd/$(NAME)/version.go
GOOS=linux GOARCH=amd64 go build -o "$@" "$(PACKAGE)/cmd/$(NAME)"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags '-s -w -extldflags "-static"' -o "$@" "$(PACKAGE)/cmd/$(NAME)"
build/bin/linux-arm64: $(GOFILES) cmd/$(NAME)/version.go
GOOS=linux GOARCH=arm64 go build -o "$@" "$(PACKAGE)/cmd/$(NAME)"
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags '-s -w -extldflags "-static"' -o "$@" "$(PACKAGE)/cmd/$(NAME)"
build/bin/darwin-amd64: $(GOFILES) cmd/$(NAME)/version.go
GOOS=darwin GOARCH=amd64 go build -o "$@" "$(PACKAGE)/cmd/$(NAME)"
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags '-s -w -extldflags "-static"' -o "$@" "$(PACKAGE)/cmd/$(NAME)"
build/bin/darwin-arm64: $(GOFILES) cmd/$(NAME)/version.go
GOOS=darwin GOARCH=arm64 go build -o "$@" "$(PACKAGE)/cmd/$(NAME)"
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags '-s -w -extldflags "-static"' -o "$@" "$(PACKAGE)/cmd/$(NAME)"
build/bin/freebsd-amd64: $(GOFILES) cmd/$(NAME)/version.go
GOOS=freebsd GOARCH=amd64 go build -o "$@" "$(PACKAGE)/cmd/$(NAME)"
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -trimpath -ldflags '-s -w -extldflags "-static"' -o "$@" "$(PACKAGE)/cmd/$(NAME)"
build/bin/windows-amd64.exe: $(GOFILES) cmd/$(NAME)/version.go
GOOS=windows GOARCH=amd64 go build -o "$@" "$(PACKAGE)/cmd/$(NAME)"
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath -ldflags '-s -w -extldflags "-static"' -o "$@" "$(PACKAGE)/cmd/$(NAME)"

$(GEM): rubygem/$(NAME)-$(VERSION).gem
mkdir -p $(@D)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1
1.5.0
5 changes: 2 additions & 3 deletions cmd/ejson/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"io/ioutil"
"os"

"github.com/Shopify/ejson"
Expand Down Expand Up @@ -52,7 +51,7 @@ func keygenAction(args []string, keydir string, wFlag bool) error {

if wFlag {
keyFile := fmt.Sprintf("%s/%s", keydir, pub)
err := writeFile(keyFile, append([]byte(priv), '\n'), 0440)
err := writeFile(keyFile, append([]byte(priv), '\n'), 0o440)
if err != nil {
return err
}
Expand All @@ -65,5 +64,5 @@ func keygenAction(args []string, keydir string, wFlag bool) error {

// for mocking in tests
var (
writeFile = ioutil.WriteFile
writeFile = os.WriteFile
)
4 changes: 1 addition & 3 deletions cmd/ejson/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"io"
"io/ioutil"
"os"
"runtime"
"strings"
Expand All @@ -26,7 +25,6 @@ func main() {
if runtime.GOOS != "windows" {
// Rather than using the built-in help printer, display the bundled manpages.
cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) {

if cmd, ok := data.(cli.Command); ok {
switch cmd.Name {
case "encrypt", "decrypt", "keygen":
Expand Down Expand Up @@ -79,7 +77,7 @@ func main() {
Action: func(c *cli.Context) {
var userSuppliedPrivateKey string
if c.Bool("key-from-stdin") {
stdinContent, err := ioutil.ReadAll(os.Stdin)
stdinContent, err := io.ReadAll(os.Stdin)
if err != nil {
fmt.Fprintln(os.Stderr, "Failed to read from stdin:", err)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion cmd/ejson/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

const VERSION string = "1.4.1"
const VERSION string = "1.5.0"
18 changes: 9 additions & 9 deletions crypto/boxed_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ var messageParser = regexp.MustCompile("\\AEJ\\[(\\d):([A-Za-z0-9+=/]{44}):([A-Z
// boxedMessage dumps and loads the wire format for encrypted messages. The
// schema is fairly simple:
//
// "EJ["
// SchemaVersion ( "1" )
// ":"
// EncrypterPublic :: base64-encoded 32-byte key
// ":"
// Nonce :: base64-encoded 24-byte nonce
// ":"
// Box :: base64-encoded encrypted message
// "]"
// "EJ["
// SchemaVersion ( "1" )
// ":"
// EncrypterPublic :: base64-encoded 32-byte key
// ":"
// Nonce :: base64-encoded 24-byte nonce
// ":"
// Box :: base64-encoded encrypted message
// "]"
type boxedMessage struct {
SchemaVersion int
EncrypterPublic [32]byte
Expand Down
2 changes: 1 addition & 1 deletion dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ up:
- gnu-tar
- ruby: 3.0.3
- go:
version: '1.20'
version: '1.21.4'
- bundler

commands:
Expand Down
9 changes: 4 additions & 5 deletions ejson.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"os"
"strings"

Expand All @@ -33,7 +32,7 @@ func GenerateKeypair() (pub string, priv string, err error) {
// Returns the number of bytes written and any error that might have
// occurred.
func Encrypt(in io.Reader, out io.Writer) (int, error) {
data, err := ioutil.ReadAll(in)
data, err := io.ReadAll(in)
if err != nil {
return -1, err
}
Expand Down Expand Up @@ -95,7 +94,7 @@ func EncryptFileInPlace(filePath string) (int, error) {
return -1, err
}

if err := ioutil.WriteFile(filePath, outBuffer.Bytes(), fileMode); err != nil {
if err := os.WriteFile(filePath, outBuffer.Bytes(), fileMode); err != nil {
return -1, err
}

Expand All @@ -106,7 +105,7 @@ func EncryptFileInPlace(filePath string) (int, error) {
// The private key is expected to be under 'keydir'.
// Returns error upon failure, or nil on success.
func Decrypt(in io.Reader, out io.Writer, keydir string, userSuppliedPrivateKey string) error {
data, err := ioutil.ReadAll(in)
data, err := io.ReadAll(in)
if err != nil {
return err
}
Expand Down Expand Up @@ -168,7 +167,7 @@ func DecryptFile(filePath, keydir string, userSuppliedPrivateKey string) ([]byte
func readPrivateKeyFromDisk(pubkey [32]byte, keydir string) (privkey string, err error) {
keyFile := fmt.Sprintf("%s/%x", keydir, pubkey)
var fileContents []byte
fileContents, err = ioutil.ReadFile(keyFile)
fileContents, err = os.ReadFile(keyFile)
if err != nil {
err = fmt.Errorf("couldn't read key file (%s)", err.Error())
return
Expand Down
22 changes: 11 additions & 11 deletions ejson_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ejson

import (
"io/ioutil"
"os"
"path"
"regexp"
Expand Down Expand Up @@ -31,7 +30,7 @@ func TestGenerateKeypair(t *testing.T) {
}

func setData(path string, data []byte) error {
tmpFile, err := os.OpenFile(path, os.O_TRUNC|os.O_WRONLY, 0600)
tmpFile, err := os.OpenFile(path, os.O_TRUNC|os.O_WRONLY, 0o600)
if err != nil {
return err
}
Expand All @@ -43,13 +42,13 @@ func setData(path string, data []byte) error {
}

func TestEncryptFileInPlace(t *testing.T) {
tempDir, err := ioutil.TempDir("", "ejson_keys")
tempDir, err := os.MkdirTemp("", "ejson_keys")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tempDir)

tempFile, err := ioutil.TempFile(tempDir, "ejson_test")
tempFile, err := os.CreateTemp(tempDir, "ejson_test")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -86,7 +85,8 @@ func TestEncryptFileInPlace(t *testing.T) {
setData(tempFileName, []byte(`{"_public_key": "`+validPubKey+`", "a": "b"}`))

_, err := EncryptFileInPlace(tempFileName)
output, err := ioutil.ReadFile(tempFileName)
So(err, ShouldBeNil)
output, err := os.ReadFile(tempFileName)
So(err, ShouldBeNil)
Convey("should encrypt the file", func() {
So(err, ShouldBeNil)
Expand All @@ -99,33 +99,33 @@ func TestEncryptFileInPlace(t *testing.T) {
setData(tempFileName, []byte(`{"_public_key": "`+validPubKey+"\", \"a\": \"b\nc\"\n}"))

_, err := EncryptFileInPlace(tempFileName)
output, err := ioutil.ReadFile(tempFileName)
So(err, ShouldBeNil)
output, err := os.ReadFile(tempFileName)
So(err, ShouldBeNil)
Convey("should encrypt the file", func() {
So(err, ShouldBeNil)
match := regexp.MustCompile(`{"_public_key": "8d8.*", "a": "EJ.*"`+"\n}")
match := regexp.MustCompile(`{"_public_key": "8d8.*", "a": "EJ.*"` + "\n}")
So(match.Find(output), ShouldNotBeNil)
})
})

})
}

func TestDecryptFile(t *testing.T) {
tempDir, err := ioutil.TempDir("", "ejson_keys")
tempDir, err := os.MkdirTemp("", "ejson_keys")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tempDir)

tempFile, err := ioutil.TempFile(tempDir, "ejson_test")
tempFile, err := os.CreateTemp(tempDir, "ejson_test")
if err != nil {
t.Fatal(err)
}
tempFile.Close()
tempFileName := tempFile.Name()
validKeyPath := path.Join(tempDir, validPubKey)
if err = ioutil.WriteFile(validKeyPath, []byte(validPrivKey), 0600); err != nil {
if err = os.WriteFile(validKeyPath, []byte(validPrivKey), 0o600); err != nil {
t.Fatal(err)
}

Expand Down
19 changes: 9 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
module github.com/Shopify/ejson

go 1.18
go 1.21.4

require (
github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad
github.com/smartystreets/goconvey v1.6.4
github.com/urfave/cli v1.22.4
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
github.com/smartystreets/goconvey v1.8.1
github.com/urfave/cli v1.22.14
golang.org/x/crypto v0.15.0
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/smartystreets/assertions v1.0.1 // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/smarty/assertions v1.15.0 // indirect
golang.org/x/sys v0.14.0 // indirect
)
60 changes: 32 additions & 28 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad h1:Qk76DOWdOp+GlyDKBAG3Klr9cn7N+LcYc82AZ2S7+cA=
github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad/go.mod h1:mPKfmRa823oBIgl2r20LeMSpTAteW5j7FLkc0vjmzyQ=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0=
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w=
github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA=
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY=
github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec=
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/urfave/cli v1.22.14 h1:ebbhrRiGK2i4naQJr+1Xj92HXZCrK7MsyTS/ob3HnAk=
github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA=
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions json/walker.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ func CollapseMultilineStringLiterals(data []byte) ([]byte, error) {
if inString && c == '\n' {
buf = append(buf, []byte{'\\', 'n'}...)
continue
} else if inString && c == '\r' {
} else if inString && c == '\r' {
buf = append(buf, []byte{'\\', 'r'}...)
continue
}
}
buf = append(buf, c)
switch v := scanner.Step(&scanner, int(c)); v {
case json.ScanContinue:
Expand Down
2 changes: 1 addition & 1 deletion json/walker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var walkTestCases = []testCase{

var collapseTestCases = []testCase{
{
"{\"a\": \"b\r\nc\nd\"\r\n}",
"{\"a\": \"b\r\nc\nd\"\r\n}",
"{\"a\": \"b\\r\\nc\\nd\"\r\n}",
},
}

0 comments on commit 4719b8c

Please sign in to comment.