-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/text: panic in regionGroupDist #43834
Comments
The function is
closing as working as intended, please comment/reopen if you disagree |
@seankhliao the function being called is Also note that the panic is not "failed to parse", it's an index out of bounds exception... |
@seankhliao also note there's no direct calls to This is a bug, please re-open. |
Reopening for evaluation. |
I see, but is there a way to trigger it from the exposed api? |
Yes, that's what led me to file a bug. It's currently impacting a production service: https://github.com/google/exposure-notifications-verification-server/blob/79e397e0f917c78f1d3fe388beeb25e14928095f/internal/i18n/i18n.go#L93 |
right, reproducer using public api: package main
import (
"fmt"
"golang.org/x/text/language"
)
func main() {
desired, _, err := language.ParseAcceptLanguage("en-ZZ")
fmt.Println(desired, err)
matcher := language.NewMatcher([]language.Tag{language.English})
t, i, c := matcher.Match(desired...)
fmt.Println(t, i, c)
} |
CC: @mpvl This was handed off by the COVID project. Any chance this can get a bump in priority for a fix? They have a workaround using |
Change https://golang.org/cl/305469 mentions this issue: |
Regions are encoded starting from 1. However, one of the region-related tables assumed 0-based indices. This caused a crash when used with ZZ, the largest region. Fixes golang/go#43834 Change-Id: Iaed6b9d2683cd50504e6d33c8a6df8b21dd1687d Reviewed-on: https://go-review.googlesource.com/c/text/+/305469 Trust: Marcel van Lohuizen <mpvl@golang.org> Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Seth Vargo <sethvargo@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes and HEAD too
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Attempted to ParseAcceptLanguage a non-existent language
us-zz
. There's a failing test as a PR at golang/text#17.What did you expect to see?
Not a panic.
What did you see instead?
A panic.
This is especially concerning since some people pass user-provided data to canonicalize (e.g. the
Accept-Lang
header).The text was updated successfully, but these errors were encountered: