Repository: gin-gonic/gin
Pull request #4268 (2025-06-17 00:33:29)

chore(deps): bump github.com/ugorji/go/codec from 1.2.12 to 1.3.0
Bumps [github.com/ugorji/go/codec](https://github.com/ugorji/go) from 1.2.12 to 1.3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/ugorji/go/releases">github.com/ugorji/go/codec's releases</a>.</em></p>
<blockquote>
<h2>1.3.0</h2>
<p>Release 1.3.0</p>
<p>Today, we release v1.3.0 of go-codec.</p>
<p>This is a BIG production release of go-codec. We encourage all users to upgrade immediately.</p>
<p>Highlights:</p>
<ul>
<li>codecgen removed</li>
<li>benchmarks moved completely to go-codec-bench/codec package</li>
<li>introduce generics extensively within unexported code (not exposed to consumers)</li>
<li>built atop generics, introduce monomorphization for optimized code execution</li>
<li>dramatic performance improvement: up to 18% on encode and 49% on decode</li>
<li>many architectural refactoring cleanup for better code</li>
<li>many fixes, including zero copy, trie for struct field lookup,</li>
<li>support NilCollectionToZeroLength: allowing encoding a nil collection as [] not null in json, etc</li>
<li>json: support TimeFormat and BytesFormat in json, for comprehensive support when encoding time.Time and []byte</li>
<li>numerous architectural clean ups and bug fixes leading to much more robust code</li>
</ul>
<p>As noted above, this release is up to 18% faster on encode and 49% faster on decode,
much more robust and provides better support for json and handling nil collections.</p>
<p>As a consequence of the changes, we now support at least 4 major releases of go.
v1.3.0 supports go 1.21+ (ie last 2+ years of go releases).</p>
<p>The main goal has always been to provide the most feature-rich and performant package
for encoding and decoding of multiple popular binary and text formats in a consistent way.</p>
<p>We believe we continue to achieve that!</p>
<h2>1.2.14</h2>
<p>Release 1.2.14</p>
<p>This is a production release of go-codec.</p>
<p>While effectively equivalent to v1.2.13, this release serves as:</p>
<ul>
<li>cutover point in the git trunk where v1.3 development begins</li>
<li>last v1.2 release on the main git trunk -
subsequent patch releases (if needed e.g. v1.2.15) will require a release branch.</li>
</ul>
<h2>1.2.13</h2>
<p>Release 1.2.13</p>
<p>This is a production release of go-codec.</p>
<p>Changes include:</p>
<ul>
<li>leading zeros are not allowed in decimal numbers</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/ugorji/go/commit/2f58d581a94460aeeed354c45a152729088004d0"><code>2f58d58</code></a> github workflow: no need to go get go-cmp package, since it is referenced in ...</li>
<li><a href="https://github.com/ugorji/go/commit/d08e9dff4c21ff3211de9ca7e159ee85aeff8002"><code>d08e9df</code></a> codec: nit (remove comments)</li>
<li><a href="https://github.com/ugorji/go/commit/2630ac4de171cee1552de10ce579ec684cbf4f26"><code>2630ac4</code></a> codec: test: call testEqualOpts with right set of interfaces to ignoreunexpor...</li>
<li><a href="https://github.com/ugorji/go/commit/1bed99c4992d3f2ba0189f66336d529e4f8f2fee"><code>1bed99c</code></a> codec: add go-cmp test dependency to go.mod, go.sum</li>
<li><a href="https://github.com/ugorji/go/commit/622e8765a38da83b89b367c663223365d69342ac"><code>622e876</code></a> codec: github actions: add cache: false to resolve repo go.sum missing</li>
<li><a href="https://github.com/ugorji/go/commit/f45b40aa9b94b5688fa46c662b40111293e8a051"><code>f45b40a</code></a> codec: simplify field name precedence support</li>
<li><a href="https://github.com/ugorji/go/commit/1bd7e924be0c7026c273c211e204ece4363f008a"><code>1bd7e92</code></a> codec: fix testEqual support for diff</li>
<li><a href="https://github.com/ugorji/go/commit/047fd14f5c4eb80d6299cda8b2627915d4b6406c"><code>047fd14</code></a> codec: bench: add io with bufsize=0 to quicksuite, and other nits (use fmt.Sp...</li>
<li><a href="https://github.com/ugorji/go/commit/707f480b67a9ff668abfbf8d06347e246bc92488"><code>707f480</code></a> codec: bench: one pass check should handle recover while printing name of format</li>
<li><a href="https://github.com/ugorji/go/commit/0885686c3e925682a4282d37372779e269ec8039"><code>0885686</code></a> codec: always log BenchOnePass output regardless of test.v flag</li>
<li>Additional commits viewable in <a href="https://github.com/ugorji/go/compare/v1.2.12...codec/v1.3.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/ugorji/go/codec&package-manager=go_modules&previous-version=1.2.12&new-version=1.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/context.go b/context.go
index bf12830..b184678 100644
--- a/context.go
+++ b/context.go
@@ -216,6 +216,14 @@ func (c *Context) AbortWithStatus(code int) {
 	c.Abort()
 }
 
+// AbortWithStatusJSON calls `Abort()` and then `PureJSON` internally.
+// This method stops the chain, writes the status code and return a JSON body without escaping.
+// It also sets the Content-Type as "application/json".
+func (c *Context) AbortWithStatusPureJSON(code int, jsonObj any) {
+	c.Abort()
+	c.PureJSON(code, jsonObj)
+}
+
 // AbortWithStatusJSON calls `Abort()` and then `JSON` internally.
 // This method stops the chain, writes the status code and return a JSON body.
 // It also sets the Content-Type as "application/json".
diff --git a/go.mod b/go.mod
index 1ee9d8b..9193bd2 100644
--- a/go.mod
+++ b/go.mod
@@ -14,7 +14,7 @@ require (
 	github.com/pelletier/go-toml/v2 v2.2.4
 	github.com/quic-go/quic-go v0.53.0
 	github.com/stretchr/testify v1.10.0
-	github.com/ugorji/go/codec v1.2.12
+	github.com/ugorji/go/codec v1.3.0
 	golang.org/x/net v0.41.0
 	google.golang.org/protobuf v1.36.6
 )
diff --git a/go.sum b/go.sum
index 979c20d..ab2a775 100644
--- a/go.sum
+++ b/go.sum
@@ -25,8 +25,8 @@ github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
 github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
 github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
 github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
-github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
-github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
+github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
+github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
 github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
@@ -61,8 +61,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
 github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
 github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
 github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
-github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
-github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
+github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
+github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
 go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
 go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
 golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=


Test patch:
diff --git a/context_test.go b/context_test.go
index fe3ccd6..74f0842 100644
--- a/context_test.go
+++ b/context_test.go
@@ -1680,6 +1680,32 @@ func TestContextAbortWithStatusJSON(t *testing.T) {
 	assert.JSONEq(t, "{\"foo\":\"fooValue\",\"bar\":\"barValue\"}", jsonStringBody)
 }
 
+func TestContextAbortWithStatusPureJSON(t *testing.T) {
+	w := httptest.NewRecorder()
+	c, _ := CreateTestContext(w)
+	c.index = 4
+
+	in := new(testJSONAbortMsg)
+	in.Bar = "barValue"
+	in.Foo = "fooValue"
+
+	c.AbortWithStatusPureJSON(http.StatusUnsupportedMediaType, in)
+
+	assert.Equal(t, abortIndex, c.index)
+	assert.Equal(t, http.StatusUnsupportedMediaType, c.Writer.Status())
+	assert.Equal(t, http.StatusUnsupportedMediaType, w.Code)
+	assert.True(t, c.IsAborted())
+
+	contentType := w.Header().Get("Content-Type")
+	assert.Equal(t, "application/json; charset=utf-8", contentType)
+
+	buf := new(bytes.Buffer)
+	_, err := buf.ReadFrom(w.Body)
+	require.NoError(t, err)
+	jsonStringBody := buf.String()
+	assert.JSONEq(t, "{\"foo\":\"fooValue\",\"bar\":\"barValue\"}", jsonStringBody)
+}
+
 func TestContextError(t *testing.T) {
 	c, _ := CreateTestContext(httptest.NewRecorder())
 	assert.Empty(t, c.Errors)