diff --git a/stripe.go b/stripe.go index 9be3fc607d..67b5e6e759 100644 --- a/stripe.go +++ b/stripe.go @@ -977,6 +977,11 @@ func ParseID(data []byte) (string, bool) { return "", false } + // Edge case that should never happen; found via fuzzing + if s == "\"" { + return "", false + } + return s[1 : len(s)-1], true } diff --git a/stripe_test.go b/stripe_test.go index 467ed81504..0ddea312fb 100644 --- a/stripe_test.go +++ b/stripe_test.go @@ -777,6 +777,13 @@ func TestParseID(t *testing.T) { assert.Equal(t, "", id) assert.False(t, ok) } + + // Edge case that should never happen; found via fuzzing + { + id, ok := ParseID([]byte(`"`)) + assert.Equal(t, "", id) + assert.False(t, ok) + } } // TestMultipleAPICalls will fail the test run if a race condition is thrown while running multiple NewRequest calls.