diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d0f3036d1..457405146 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - go-version: [1.13.x, 1.14.x] + go-version: [1.14.x, 1.15.x] os: [macos-latest, windows-latest, ubuntu-latest] env: GO111MODULE: on diff --git a/Dockerfile.build b/Dockerfile.build index a2e3ecbf1..16af7cd1a 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -32,7 +32,7 @@ RUN npm install -g --no-progress yarn \ # Install golangci RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0 # Installing buffalo binary -RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/buffalo@v0.16.14 | sh +RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/buffalo@v0.16.15 | sh RUN go get github.com/gobuffalo/buffalo-pop/v2 RUN buffalo version diff --git a/Dockerfile.slim.build b/Dockerfile.slim.build index 57320e9b3..788b59d1a 100644 --- a/Dockerfile.slim.build +++ b/Dockerfile.slim.build @@ -17,7 +17,7 @@ RUN npm i -g --no-progress yarn \ && yarn config set yarn-offline-mirror-pruning true # Pulling docker binary from releases -RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/buffalo@v0.16.14 | sh +RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/buffalo@v0.16.15 | sh RUN go get github.com/gobuffalo/buffalo-pop/v2 RUN buffalo version diff --git a/binding/binding.go b/binding/binding.go index e77eb6974..e78de96be 100644 --- a/binding/binding.go +++ b/binding/binding.go @@ -2,8 +2,10 @@ package binding import ( "net/http" + "time" "github.com/gobuffalo/buffalo/binding/decoders" + "github.com/gobuffalo/nulls" "github.com/monoculum/formam" ) @@ -14,16 +16,16 @@ var ( // information on how this impacts file uploads. MaxFileMemory int64 = 5 * 1024 * 1024 - formDecoder = formam.NewDecoder(&formam.DecoderOptions{ - TagName: "form", - IgnoreUnknownKeys: true, - }) + // formDecoder (formam) that will be used across ContentTypeBinders + formDecoder = buildFormDecoder() // BaseRequestBinder is an instance of the requestBinder, it comes with preconfigured // content type binders for HTML, JSON, XML and Files, as well as custom types decoders // for time.Time and nulls.Time BaseRequestBinder = NewRequestBinder( - NewHTMLContentTypeBinder(formDecoder), + HTMLContentTypeBinder{ + decoder: formDecoder, + }, JSONContentTypeBinder{}, XMLRequestTypeBinder{}, FileRequestTypeBinder{ @@ -32,6 +34,19 @@ var ( ) ) +// buildFormDecoder that will be used in the package. This method adds some custom decoders for time.Time and nulls.Time. +func buildFormDecoder() *formam.Decoder { + decoder := formam.NewDecoder(&formam.DecoderOptions{ + TagName: "form", + IgnoreUnknownKeys: true, + }) + + decoder.RegisterCustomType(decoders.TimeDecoderFn(), []interface{}{time.Time{}}, nil) + decoder.RegisterCustomType(decoders.NullTimeDecoderFn(), []interface{}{nulls.Time{}}, nil) + + return decoder +} + // RegisterTimeFormats allows to add custom time layouts that // the binder will be able to use for decoding. func RegisterTimeFormats(layouts ...string) { diff --git a/binding/html_content_type_binder.go b/binding/html_content_type_binder.go index 0450bc48d..dd69eb56d 100644 --- a/binding/html_content_type_binder.go +++ b/binding/html_content_type_binder.go @@ -2,10 +2,7 @@ package binding import ( "net/http" - "time" - "github.com/gobuffalo/buffalo/binding/decoders" - "github.com/gobuffalo/nulls" "github.com/monoculum/formam" ) @@ -14,17 +11,6 @@ type HTMLContentTypeBinder struct { decoder *formam.Decoder } -// NewHTMLContentTypeBinder returns an instance of HTMLContentTypeBinder with -// custom type decoders registered for Time and nulls.Time -func NewHTMLContentTypeBinder(decoder *formam.Decoder) HTMLContentTypeBinder { - decoder.RegisterCustomType(decoders.TimeDecoderFn(), []interface{}{time.Time{}}, nil) - decoder.RegisterCustomType(decoders.NullTimeDecoderFn(), []interface{}{nulls.Time{}}, nil) - - return HTMLContentTypeBinder{ - decoder: decoder, - } -} - // ContentTypes that will be used to identify HTML requests func (ht HTMLContentTypeBinder) ContentTypes() []string { return []string{ diff --git a/go.mod b/go.mod index 8f76c8b87..be9ef8141 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gobuffalo/clara/v2 v2.0.2 github.com/gobuffalo/envy v1.9.0 github.com/gobuffalo/events v1.4.1 - github.com/gobuffalo/flect v0.2.1 + github.com/gobuffalo/flect v0.2.2 github.com/gobuffalo/genny/v2 v2.0.6 github.com/gobuffalo/github_flavored_markdown v1.1.0 github.com/gobuffalo/helpers v0.6.1 @@ -34,7 +34,7 @@ require ( github.com/markbates/refresh v1.11.1 github.com/markbates/safe v1.0.1 github.com/markbates/sigtx v1.0.0 - github.com/monoculum/formam v0.0.0-20200527175922-6f3cce7a46cf + github.com/monoculum/formam v0.0.0-20200905010316-d7a8fbd33677 github.com/sirupsen/logrus v1.5.0 github.com/spf13/cobra v0.0.6 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index b77c0aa8e..83f7c8e6d 100644 --- a/go.sum +++ b/go.sum @@ -258,6 +258,8 @@ github.com/gobuffalo/flect v0.2.0 h1:EWCvMGGxOjsgwlWaP+f4+Hh6yrrte7JeFL2S6b+0hdM github.com/gobuffalo/flect v0.2.0/go.mod h1:W3K3X9ksuZfir8f/LrfVtWmCDQFfayuylOJ7sz/Fj80= github.com/gobuffalo/flect v0.2.1 h1:GPoRjEN0QObosV4XwuoWvSd5uSiL0N3e91/xqyY4crQ= github.com/gobuffalo/flect v0.2.1/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc= +github.com/gobuffalo/flect v0.2.2 h1:PAVD7sp0KOdfswjAw9BpLCU9hXo7wFSzgpQ+zNeks/A= +github.com/gobuffalo/flect v0.2.2/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc= github.com/gobuffalo/genny v0.0.0-20180924032338-7af3a40f2252/go.mod h1:tUTQOogrr7tAQnhajMSH6rv1BVev34H2sa1xNHMy94g= github.com/gobuffalo/genny v0.0.0-20181003150629-3786a0744c5d/go.mod h1:WAd8HmjMVrnkAZbmfgH5dLBUchsZfqzp/WS5sQz+uTM= github.com/gobuffalo/genny v0.0.0-20181005145118-318a41a134cc/go.mod h1:WAd8HmjMVrnkAZbmfgH5dLBUchsZfqzp/WS5sQz+uTM= @@ -868,10 +870,8 @@ github.com/monoculum/formam v0.0.0-20190730134247-0612307a4099/go.mod h1:JKa2av1 github.com/monoculum/formam v0.0.0-20190830100315-7ff9597b1407/go.mod h1:JKa2av1XVkGjhxdLS59nDoXa2JpmIHpnURWNbzCtXtc= github.com/monoculum/formam v0.0.0-20191229172733-952f0766a724 h1:qlTmDrFZLQIGXnd1JE58dqyLnKyIJjR9WBeDQcT3O8w= github.com/monoculum/formam v0.0.0-20191229172733-952f0766a724/go.mod h1:JKa2av1XVkGjhxdLS59nDoXa2JpmIHpnURWNbzCtXtc= -github.com/monoculum/formam v0.0.0-20200316225015-49f0baed3a1b h1:BvSZE/bUSz180cQzAEDVOh7seh57UNBlcGAte0CQ8l4= -github.com/monoculum/formam v0.0.0-20200316225015-49f0baed3a1b/go.mod h1:JKa2av1XVkGjhxdLS59nDoXa2JpmIHpnURWNbzCtXtc= -github.com/monoculum/formam v0.0.0-20200527175922-6f3cce7a46cf h1:DJ+VDi88ZNh+C3HkJlNtfWIeOdLPxFjbtwGbWa/D3sY= -github.com/monoculum/formam v0.0.0-20200527175922-6f3cce7a46cf/go.mod h1:JKa2av1XVkGjhxdLS59nDoXa2JpmIHpnURWNbzCtXtc= +github.com/monoculum/formam v0.0.0-20200905010316-d7a8fbd33677 h1:N11HMdhT5DtkXsQQo3xPFipjvG7QwzKa9MBupRQqXaU= +github.com/monoculum/formam v0.0.0-20200905010316-d7a8fbd33677/go.mod h1:JKa2av1XVkGjhxdLS59nDoXa2JpmIHpnURWNbzCtXtc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= diff --git a/render/js_test.go b/render/js_test.go index 7536857f3..335e0d84b 100644 --- a/render/js_test.go +++ b/render/js_test.go @@ -124,6 +124,9 @@ func Test_JavaScript_HTML_Partial(t *testing.T) { bb := &bytes.Buffer{} r.NoError(h.Render(bb, Data{})) - pre := `let a = "\x3Cdiv` - r.True(strings.HasPrefix(bb.String(), pre)) + r.Contains(bb.String(), `id`) + r.Contains(bb.String(), `foo`) + + // To check it has escaped the partial + r.NotContains(bb.String(), `
`) } diff --git a/runtime/version.go b/runtime/version.go index 8c7cbecf6..52302ec37 100644 --- a/runtime/version.go +++ b/runtime/version.go @@ -1,4 +1,4 @@ package runtime // Version is the current version of the buffalo binary -var Version = "v0.16.14" +var Version = "v0.16.15"