From 43fe48e8a0f44af783116cdb010725e6bb50255f Mon Sep 17 00:00:00 2001 From: Zain Qureshi <43629888+ZainnQureshii@users.noreply.github.com> Date: Tue, 29 Sep 2026 15:14:45 +0200 Subject: [PATCH] docs: fix SecureJSON default prefix and default-binding example output (#4861) The SecureJSON docs and the Context.SecureJSON comment said the default prefix is "while(1),". The engine sets secureJSONPrefix to "while(1);" (gin.go), and the example output a few lines below already shows the semicolon. The default-values binding example printed a "Colors" field that the Person struct does not have; the struct's array field is Addresses with default "foo bar", which binds to ["foo","bar"]. Co-authored-by: Claude Opus 5.5 --- context.go | 2 +- docs/doc.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/context.go b/context.go index a6add8a6..582d00f2 100644 --- a/context.go +++ b/context.go @@ -1236,7 +1236,7 @@ func (c *Context) IndentedJSON(code int, obj any) { } // SecureJSON serializes the given struct as Secure JSON into the response body. -// Default prepends "while(1)," to response body if the given struct is array values. +// Default prepends "while(1);" to response body if the given struct is array values. // It also sets the Content-Type as "application/json". func (c *Context) SecureJSON(code int, obj any) { c.Render(code, render.SecureJSON{Prefix: c.engine.secureJSONPrefix, Data: obj}) diff --git a/docs/doc.md b/docs/doc.md index 3f0c94ea..16102841 100644 --- a/docs/doc.md +++ b/docs/doc.md @@ -1167,7 +1167,7 @@ func main() { ```sh curl -X POST http://localhost:8080/person -{"Name":"William","Age":10,"Friends":["Will","Bill"],"Colors":["red","blue"],"LapTimes":[1,2,3]} +{"Name":"William","Age":10,"Friends":["Will","Bill"],"Addresses":["foo","bar"],"LapTimes":[1,2,3]} ``` NOTE: For default [collection values](#collection-format-for-arrays), the following rules apply: @@ -1762,7 +1762,7 @@ func main() { #### SecureJSON -Using SecureJSON to prevent json hijacking. Default prepends `"while(1),"` to response body if the given struct is array values. +Using SecureJSON to prevent json hijacking. Default prepends `"while(1);"` to response body if the given struct is array values. ```go func main() {