mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 05:16:35 +08:00
gin.Context: check key type on calling Value when key is 0
The type of context key is part of the key used in the context.Context type. Many packages uses zero and an unexported type to inject values into context.Context.
This commit is contained in:
parent
b2d4185eec
commit
8e7df33dd6
@ -1200,7 +1200,7 @@ func (c *Context) Err() error {
|
||||
// if no value is associated with key. Successive calls to Value with
|
||||
// the same key returns the same result.
|
||||
func (c *Context) Value(key any) any {
|
||||
if key == 0 {
|
||||
if _, ok := key.(int); ok && key == 0 {
|
||||
return c.Request
|
||||
}
|
||||
if key == ContextKey {
|
||||
|
Loading…
x
Reference in New Issue
Block a user