minor addition to #8238

This commit is contained in:
Christopher Brown
2018-02-09 20:08:39 -06:00
parent 396e7513ec
commit c1b6e8792c
2 changed files with 7 additions and 5 deletions

View File

@@ -894,14 +894,10 @@ func (a *App) ImageProxyAdder() func(string) string {
}
return func(url string) string {
if url == "" || strings.HasPrefix(url, siteURL) || strings.HasPrefix(url, proxyURL) {
if url == "" || url[0] == '/' || strings.HasPrefix(url, siteURL) || strings.HasPrefix(url, proxyURL) {
return url
}
if url[0] == '/' {
url = siteURL + url[1:]
}
switch proxyType {
case "atmos/camo":
mac := hmac.New(sha1.New, []byte(options))

View File

@@ -221,6 +221,12 @@ func TestImageProxy(t *testing.T) {
ImageURL: "http://mymattermost.com/myimage",
ProxiedImageURL: "http://mymattermost.com/myimage",
},
"willnorris/imageproxy_PathOnly": {
ProxyType: "willnorris/imageproxy",
ProxyURL: "https://127.0.0.1",
ImageURL: "/myimage",
ProxiedImageURL: "/myimage",
},
"willnorris/imageproxy_EmptyImageURL": {
ProxyType: "willnorris/imageproxy",
ProxyURL: "https://127.0.0.1",