fix: use equalFold() instead of lower and compare (#13624)

This commit is contained in:
Harshavardhana 2021-11-10 08:12:50 -08:00 committed by GitHub
parent 03725dc015
commit ea820b30bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 10 additions and 9 deletions

View file

@ -110,7 +110,7 @@ func cacheControlOpts(o ObjectInfo) *cacheControl {
var headerVal string var headerVal string
for k, v := range m { for k, v := range m {
if strings.ToLower(k) == "cache-control" { if strings.EqualFold(k, "cache-control") {
headerVal = v headerVal = v
} }

View file

@ -47,7 +47,7 @@ func (az *warmBackendAzure) getDest(object string) string {
} }
func (az *warmBackendAzure) tier() azblob.AccessTierType { func (az *warmBackendAzure) tier() azblob.AccessTierType {
for _, t := range azblob.PossibleAccessTierTypeValues() { for _, t := range azblob.PossibleAccessTierTypeValues() {
if strings.ToLower(az.StorageClass) == strings.ToLower(string(t)) { if strings.EqualFold(az.StorageClass, string(t)) {
return t return t
} }
} }

View file

@ -382,7 +382,7 @@ func IsObjectLockLegalHoldRequested(h http.Header) bool {
// IsObjectLockGovernanceBypassSet returns true if object lock governance bypass header is set. // IsObjectLockGovernanceBypassSet returns true if object lock governance bypass header is set.
func IsObjectLockGovernanceBypassSet(h http.Header) bool { func IsObjectLockGovernanceBypassSet(h http.Header) bool {
return strings.ToLower(h.Get(AmzObjectLockBypassRetGovernance)) == "true" return strings.EqualFold(h.Get(AmzObjectLockBypassRetGovernance), "true")
} }
// IsObjectLockRequested returns true if legal hold or object lock retention headers are requested. // IsObjectLockRequested returns true if legal hold or object lock retention headers are requested.

View file

@ -46,7 +46,8 @@ func (sses3) String() string { return "SSE-S3" }
func (sses3) IsRequested(h http.Header) bool { func (sses3) IsRequested(h http.Header) bool {
_, ok := h[xhttp.AmzServerSideEncryption] _, ok := h[xhttp.AmzServerSideEncryption]
return ok && strings.ToLower(h.Get(xhttp.AmzServerSideEncryption)) != xhttp.AmzEncryptionKMS // Return only true if the SSE header is specified and does not contain the SSE-KMS value // Return only true if the SSE header is specified and does not contain the SSE-KMS value
return ok && !strings.EqualFold(h.Get(xhttp.AmzServerSideEncryption), xhttp.AmzEncryptionKMS)
} }
// ParseHTTP parses the SSE-S3 related HTTP headers and checks // ParseHTTP parses the SSE-S3 related HTTP headers and checks

View file

@ -387,7 +387,7 @@ func (s3Select *S3Select) marshal(buf *bytes.Buffer, record sql.Record) error {
FieldDelimiter: []rune(s3Select.Output.CSVArgs.FieldDelimiter)[0], FieldDelimiter: []rune(s3Select.Output.CSVArgs.FieldDelimiter)[0],
Quote: []rune(s3Select.Output.CSVArgs.QuoteCharacter)[0], Quote: []rune(s3Select.Output.CSVArgs.QuoteCharacter)[0],
QuoteEscape: []rune(s3Select.Output.CSVArgs.QuoteEscapeCharacter)[0], QuoteEscape: []rune(s3Select.Output.CSVArgs.QuoteEscapeCharacter)[0],
AlwaysQuote: strings.ToLower(s3Select.Output.CSVArgs.QuoteFields) == "always", AlwaysQuote: strings.EqualFold(s3Select.Output.CSVArgs.QuoteFields, "always"),
} }
err := record.WriteCSV(bufioWriter, opts) err := record.WriteCSV(bufioWriter, opts)
if err != nil { if err != nil {

View file

@ -179,7 +179,7 @@ func (e *PrimaryTerm) analyze(s *Select) (result qProp) {
case e.JPathExpr != nil: case e.JPathExpr != nil:
// Check if the path expression is valid // Check if the path expression is valid
if len(e.JPathExpr.PathExpr) > 0 { if len(e.JPathExpr.PathExpr) > 0 {
if e.JPathExpr.BaseKey.String() != s.From.As && strings.ToLower(e.JPathExpr.BaseKey.String()) != baseTableName { if e.JPathExpr.BaseKey.String() != s.From.As && !strings.EqualFold(e.JPathExpr.BaseKey.String(), baseTableName) {
result = qProp{err: errInvalidKeypath} result = qProp{err: errInvalidKeypath}
return return
} }

View file

@ -31,7 +31,7 @@ type Boolean bool
// Capture interface used by participle // Capture interface used by participle
func (b *Boolean) Capture(values []string) error { func (b *Boolean) Capture(values []string) error {
*b = strings.ToLower(values[0]) == "true" *b = Boolean(strings.EqualFold(values[0], "true"))
return nil return nil
} }

View file

@ -118,7 +118,7 @@ func ParseSelectStatement(s string) (stmt SelectStatement, err error) {
} }
func validateTableName(from *TableExpression) error { func validateTableName(from *TableExpression) error {
if strings.ToLower(from.Table.BaseKey.String()) != baseTableName { if !strings.EqualFold(from.Table.BaseKey.String(), baseTableName) {
return errBadTableName(errors.New("table name must be `s3object`")) return errBadTableName(errors.New("table name must be `s3object`"))
} }

View file

@ -44,7 +44,7 @@ func (e *JSONPath) StripTableAlias(tableAlias string) []*JSONPathElement {
return e.strippedPathExpr return e.strippedPathExpr
} }
hasTableAlias := e.BaseKey.String() == tableAlias || strings.ToLower(e.BaseKey.String()) == baseTableName hasTableAlias := e.BaseKey.String() == tableAlias || strings.EqualFold(e.BaseKey.String(), baseTableName)
var pathExpr []*JSONPathElement var pathExpr []*JSONPathElement
if hasTableAlias { if hasTableAlias {
pathExpr = e.PathExpr pathExpr = e.PathExpr