danielgtaylor / huma

Huma REST/HTTP API Framework for Golang with OpenAPI 3.1
https://huma.rocks/
MIT License
2.21k stars 153 forks source link

Panic in "SelectQValueFast" on string "a;," #639

Closed RangelReale closed 3 weeks ago

RangelReale commented 3 weeks ago

If an Accept header contains a sequence of "semicolon" followed by "comma", we get a panic at negotiation.go:78.

runtime error: slice bounds out of range [-1:]

Add this to negotiation/negotiation_test.go to panic:

func TestPanic(t *testing.T) {
    assert.Equal(t, "", SelectQValueFast("a;,", []string{"d", "e"}))
}