Merge 7303932ab2283f14b093dea467141cdbf772323f into d1a15347b1e45a8ee816193d3578a93bfd73b70f

This commit is contained in:
Name 2025-12-13 13:28:25 -08:00 committed by GitHub
commit 3c9c5e1923
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

3
gin.go
View File

@ -9,6 +9,7 @@ import (
"html/template"
"net"
"net/http"
"net/textproto"
"os"
"path"
"strings"
@ -485,7 +486,7 @@ func (engine *Engine) validateHeader(header string) (clientIP string, valid bool
}
items := strings.Split(header, ",")
for i := len(items) - 1; i >= 0; i-- {
ipStr := strings.TrimSpace(items[i])
ipStr := textproto.TrimString(items[i])
ip := net.ParseIP(ipStr)
if ip == nil {
break

View File

@ -8,6 +8,7 @@ import (
"encoding/xml"
"math"
"net/http"
"net/textproto"
"os"
"path"
"reflect"
@ -108,7 +109,7 @@ func parseAccept(acceptHeader string) []string {
if i := strings.IndexByte(part, ';'); i > 0 {
part = part[:i]
}
if part = strings.TrimSpace(part); part != "" {
if part = textproto.TrimString(part); part != "" {
out = append(out, part)
}
}