mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-11-01 06:35:43 +00:00
refactor: use splitn in header parser
This commit is contained in:
@@ -181,12 +181,14 @@ func ParseHeaders(headers []string) map[string]string {
|
|||||||
|
|
||||||
// Loop through the headers
|
// Loop through the headers
|
||||||
for _, header := range headers {
|
for _, header := range headers {
|
||||||
headerSplit := strings.Split(header, "=")
|
split := strings.SplitN(header, "=", 2)
|
||||||
if len(headerSplit) != 2 {
|
if len(split) != 2 {
|
||||||
log.Warn().Str("header", header).Msg("Invalid header format, skipping")
|
log.Warn().Str("header", header).Msg("Invalid header format, skipping")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
headerMap[headerSplit[0]] = SanitizeHeader(headerSplit[1])
|
key := SanitizeHeader(strings.TrimSpace(split[0]))
|
||||||
|
value := SanitizeHeader(strings.TrimSpace(split[1]))
|
||||||
|
headerMap[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the header map
|
// Return the header map
|
||||||
|
|||||||
Reference in New Issue
Block a user