-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Handle misencoding of login_source cfg in mssql #16268
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -70,15 +70,25 @@ var ( | |||||
_ convert.Conversion = &SSPIConfig{} | ||||||
) | ||||||
|
||||||
// jsonUnmarshalIgnoreErroneousBOM - due to a bug in xorm (see https://gitea.com/xorm/xorm/pulls/1957) > | ||||||
// possible that a Blob may gain an unwanted prefix of 0xff 0xfe. | ||||||
func jsonUnmarshalIgnoreErroneousBOM(bs []byte, v interface{}) error { | ||||||
json := jsoniter.ConfigCompatibleWithStandardLibrary | ||||||
err := json.Unmarshal(bs, &v) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is double indirection! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if err != nil && len(bs) > 2 && bs[0] == 0xff && bs[1] == 0xfe { | ||||||
err = json.Unmarshal(bs[2:], &v) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is double indirection! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
return err | ||||||
} | ||||||
|
||||||
// LDAPConfig holds configuration for LDAP login source. | ||||||
type LDAPConfig struct { | ||||||
*ldap.Source | ||||||
} | ||||||
|
||||||
// FromDB fills up a LDAPConfig from serialized format. | ||||||
func (cfg *LDAPConfig) FromDB(bs []byte) error { | ||||||
json := jsoniter.ConfigCompatibleWithStandardLibrary | ||||||
err := json.Unmarshal(bs, &cfg) | ||||||
err := jsonUnmarshalIgnoreErroneousBOM(bs, &cfg) | ||||||
if err != nil { | ||||||
return err | ||||||
} | ||||||
|
@@ -119,8 +129,7 @@ type SMTPConfig struct { | |||||
|
||||||
// FromDB fills up an SMTPConfig from serialized format. | ||||||
func (cfg *SMTPConfig) FromDB(bs []byte) error { | ||||||
json := jsoniter.ConfigCompatibleWithStandardLibrary | ||||||
return json.Unmarshal(bs, cfg) | ||||||
return jsonUnmarshalIgnoreErroneousBOM(bs, cfg) | ||||||
} | ||||||
|
||||||
// ToDB exports an SMTPConfig to a serialized format. | ||||||
|
@@ -137,8 +146,7 @@ type PAMConfig struct { | |||||
|
||||||
// FromDB fills up a PAMConfig from serialized format. | ||||||
func (cfg *PAMConfig) FromDB(bs []byte) error { | ||||||
json := jsoniter.ConfigCompatibleWithStandardLibrary | ||||||
return json.Unmarshal(bs, &cfg) | ||||||
return jsonUnmarshalIgnoreErroneousBOM(bs, cfg) | ||||||
} | ||||||
|
||||||
// ToDB exports a PAMConfig to a serialized format. | ||||||
|
@@ -159,8 +167,7 @@ type OAuth2Config struct { | |||||
|
||||||
// FromDB fills up an OAuth2Config from serialized format. | ||||||
func (cfg *OAuth2Config) FromDB(bs []byte) error { | ||||||
json := jsoniter.ConfigCompatibleWithStandardLibrary | ||||||
return json.Unmarshal(bs, cfg) | ||||||
return jsonUnmarshalIgnoreErroneousBOM(bs, cfg) | ||||||
} | ||||||
|
||||||
// ToDB exports an SMTPConfig to a serialized format. | ||||||
|
@@ -180,8 +187,7 @@ type SSPIConfig struct { | |||||
|
||||||
// FromDB fills up an SSPIConfig from serialized format. | ||||||
func (cfg *SSPIConfig) FromDB(bs []byte) error { | ||||||
json := jsoniter.ConfigCompatibleWithStandardLibrary | ||||||
return json.Unmarshal(bs, cfg) | ||||||
return jsonUnmarshalIgnoreErroneousBOM(bs, cfg) | ||||||
} | ||||||
|
||||||
// ToDB exports an SSPIConfig to a serialized format. | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.