summaryrefslogtreecommitdiffstats
path: root/app/post.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2018-02-09 15:41:06 -0600
committerGitHub <noreply@github.com>2018-02-09 15:41:06 -0600
commit396e7513ecc7d86b04e56745586c802e56e5d763 (patch)
tree4915a002e66ded7aefb6925caa15676ef1876097 /app/post.go
parenta4e9499714999d58f26c712df02c014f1facccf7 (diff)
downloadchat-396e7513ecc7d86b04e56745586c802e56e5d763.tar.gz
chat-396e7513ecc7d86b04e56745586c802e56e5d763.tar.bz2
chat-396e7513ecc7d86b04e56745586c802e56e5d763.zip
Don't proxy same-site image urls (#8238)
* don't proxy same-site urls * fix empty site url case
Diffstat (limited to 'app/post.go')
-rw-r--r--app/post.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/post.go b/app/post.go
index 005624605..5b0e59b23 100644
--- a/app/post.go
+++ b/app/post.go
@@ -876,6 +876,10 @@ func (a *App) imageProxyConfig() (proxyType, proxyURL, options, siteURL string)
proxyURL += "/"
}
+ if siteURL == "" || siteURL[len(siteURL)-1] != '/' {
+ siteURL += "/"
+ }
+
if cfg.ServiceSettings.ImageProxyOptions != nil {
options = *cfg.ServiceSettings.ImageProxyOptions
}
@@ -890,12 +894,12 @@ func (a *App) ImageProxyAdder() func(string) string {
}
return func(url string) string {
- if url == "" || strings.HasPrefix(url, proxyURL) {
+ if url == "" || strings.HasPrefix(url, siteURL) || strings.HasPrefix(url, proxyURL) {
return url
}
if url[0] == '/' {
- url = siteURL + url
+ url = siteURL + url[1:]
}
switch proxyType {