mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 04:35:40 +00:00
tests: fix parse header tests
This commit is contained in:
@@ -188,7 +188,7 @@ func ParseHeaders(headers []string) map[string]string {
|
|||||||
// Loop through the headers
|
// Loop through the headers
|
||||||
for _, header := range headers {
|
for _, header := range headers {
|
||||||
split := strings.SplitN(header, "=", 2)
|
split := strings.SplitN(header, "=", 2)
|
||||||
if len(split) != 2 {
|
if len(split) != 2 || strings.TrimSpace(split[0]) == "" || strings.TrimSpace(split[1]) == "" {
|
||||||
log.Warn().Str("header", header).Msg("Invalid header format, skipping")
|
log.Warn().Str("header", header).Msg("Invalid header format, skipping")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ func TestParseHeaders(t *testing.T) {
|
|||||||
t.Log("Testing parse headers with a valid string")
|
t.Log("Testing parse headers with a valid string")
|
||||||
|
|
||||||
// Create variables
|
// Create variables
|
||||||
headers := []string{"X-Hea\tder1=value1", "X-Header2=value\n2"}
|
headers := []string{"X-Hea\x00der1=value1", "X-Header2=value\n2"}
|
||||||
expected := map[string]string{
|
expected := map[string]string{
|
||||||
"X-Header1": "value1",
|
"X-Header1": "value1",
|
||||||
"X-Header2": "value2",
|
"X-Header2": "value2",
|
||||||
|
|||||||
Reference in New Issue
Block a user