Этот коммит содержится в:
=Corey Hulen
2016-04-28 17:34:56 -07:00
родитель f31108b7c4
Коммит 30418b81a5
2 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@@ -343,26 +343,46 @@ func (o *Config) SetDefaults() {
*o.EmailSettings.PushNotificationContents = GENERIC_NOTIFICATION
}
if !IsSafeLink(o.SupportSettings.TermsOfServiceLink) {
o.SupportSettings.TermsOfServiceLink = nil
}
if o.SupportSettings.TermsOfServiceLink == nil {
o.SupportSettings.TermsOfServiceLink = new(string)
*o.SupportSettings.TermsOfServiceLink = "/static/help/terms.html"
}
if !IsSafeLink(o.SupportSettings.PrivacyPolicyLink) {
o.SupportSettings.PrivacyPolicyLink = nil
}
if o.SupportSettings.PrivacyPolicyLink == nil {
o.SupportSettings.PrivacyPolicyLink = new(string)
*o.SupportSettings.PrivacyPolicyLink = "/static/help/privacy.html"
}
if !IsSafeLink(o.SupportSettings.AboutLink) {
o.SupportSettings.AboutLink = nil
}
if o.SupportSettings.AboutLink == nil {
o.SupportSettings.AboutLink = new(string)
*o.SupportSettings.AboutLink = "/static/help/about.html"
}
if !IsSafeLink(o.SupportSettings.HelpLink) {
o.SupportSettings.HelpLink = nil
}
if o.SupportSettings.HelpLink == nil {
o.SupportSettings.HelpLink = new(string)
*o.SupportSettings.HelpLink = "/static/help/help.html"
}
if !IsSafeLink(o.SupportSettings.ReportAProblemLink) {
o.SupportSettings.ReportAProblemLink = nil
}
if o.SupportSettings.ReportAProblemLink == nil {
o.SupportSettings.ReportAProblemLink = new(string)
*o.SupportSettings.ReportAProblemLink = "/static/help/report_problem.html"

Просмотреть файл

@@ -386,3 +386,17 @@ func IsValidHttpsUrl(rawUrl string) bool {
return true
}
func IsSafeLink(link *string) bool {
if link != nil {
if IsValidHttpUrl(*link) {
return true
} else if strings.HasPrefix(*link, "/") {
return true
} else {
return false
}
}
return true
}