mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-06-13 15:47:38 +08:00
fix: avoid unsafe header buffer reuse
Use safe string copies for pooled header buffers and simplify case-insensitive lookup buffering now that the pseudo stack path was ineffective. This addresses review concerns without changing the routing semantics.
This commit is contained in:
parent
2d4aefc86e
commit
57847fa446
3 changed files with 4 additions and 13 deletions
|
|
@ -145,7 +145,7 @@ var methodNotAllowedHandler HandlerFunc = func(c *Context) {
|
|||
allowHeader = append(allowHeader, method...)
|
||||
}
|
||||
c.allowHeaderBuf = allowHeader[:0]
|
||||
c.Writer.Header().Set("Allow", BytesToString(allowHeader))
|
||||
c.Writer.Header().Set("Allow", string(allowHeader))
|
||||
c.Status(http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
|
@ -810,7 +810,7 @@ func (engine *Engine) handleRequest(c *Context) {
|
|||
ciPath, found := rootNode.findCaseInsensitivePathWithBuffer(requestPath, c.fixedPathBuf, engine.RedirectTrailingSlash)
|
||||
if found {
|
||||
c.fixedPathBuf = ciPath[:0]
|
||||
c.Redirect(http.StatusMovedPermanently, BytesToString(ciPath)) // 301 永久重定向到修正后的路径
|
||||
c.Redirect(http.StatusMovedPermanently, string(ciPath)) // 301 永久重定向到修正后的路径
|
||||
return
|
||||
}
|
||||
c.fixedPathBuf = ciPath[:0]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue