fix prefix check when returning early (#2503)

This commit is contained in:
Dustin Decker 2024-02-24 09:15:54 -08:00 committed by GitHub
parent 8a825fde52
commit 2d2ca4d3d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,12 +53,12 @@ func isMySQLErrorDeterminate(err error) bool {
func parseConnStr(connStr string) (hostAndDB, params string, err error) {
// expected form: [subprotocol:]//[user:password@]HOST[/DB][?key=val[&key=val]]
hostAndDB, params, found := strings.Cut(connStr, "?")
if !found {
return hostAndDB, "", nil
}
if !strings.HasPrefix(hostAndDB, "//") {
return "", "", errors.New("expected host to start with //")
}
if !found {
return hostAndDB, "", nil
}
splitParams := strings.Split(params, "&")
for i, param := range splitParams {
if strings.Contains(strings.ToLower(param), "allowallfiles") {