diff options
author | =Corey Hulen <corey@hulen.com> | 2016-04-28 17:34:56 -0700 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2016-04-28 17:34:56 -0700 |
commit | 30418b81a51a73f0d9e8b9c20a39e42f1db28061 (patch) | |
tree | 0e8c6e17c5d8b82a8422e57429632c0681bef6f3 | |
parent | f31108b7c4ae9800c4142bb83ae89d00ab865f92 (diff) | |
download | chat-30418b81a51a73f0d9e8b9c20a39e42f1db28061.tar.gz chat-30418b81a51a73f0d9e8b9c20a39e42f1db28061.tar.bz2 chat-30418b81a51a73f0d9e8b9c20a39e42f1db28061.zip |
Fixing help links
-rw-r--r-- | model/config.go | 20 | ||||
-rw-r--r-- | model/utils.go | 14 |
2 files changed, 34 insertions, 0 deletions
diff --git a/model/config.go b/model/config.go index fd033c7cf..4bb2a7a49 100644 --- a/model/config.go +++ b/model/config.go @@ -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" diff --git a/model/utils.go b/model/utils.go index 03215490d..d9b06bd01 100644 --- a/model/utils.go +++ b/model/utils.go @@ -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 +} |