Browse Source

Prevent use of double sub-path and incorrect asset path in manifest (#14827)

MakeAbsoluteAssetURL should just url join the static url prefix on to appurl
if it is not an absolute path - this is because StaticURLPrefix is an absolute
prefix not a relative prefix to the app sub url.

Fix #14422

Signed-off-by: Andrew Thornton <art27@cantab.net>
tags/v1.15.0-dev
zeripath GitHub 4 years ago
parent
commit
dc739870d6
2 changed files with 7 additions and 4 deletions
  1. +1
    -1
      modules/setting/setting.go
  2. +6
    -3
      modules/setting/setting_test.go

+ 1
- 1
modules/setting/setting.go View File

@@ -1090,7 +1090,7 @@ func MakeAbsoluteAssetURL(appURL string, staticURLPrefix string) string {
}

// StaticURLPrefix is just a path
return strings.TrimSuffix(appURL, "/") + strings.TrimSuffix(staticURLPrefix, "/")
return util.URLJoin(appURL, strings.TrimSuffix(staticURLPrefix, "/"))
}

return strings.TrimSuffix(staticURLPrefix, "/")


+ 6
- 3
modules/setting/setting_test.go View File

@@ -18,9 +18,12 @@ func TestMakeAbsoluteAssetURL(t *testing.T) {
assert.Equal(t, "https://localhost:1234/foo", MakeAbsoluteAssetURL("https://localhost:1234", "/foo"))
assert.Equal(t, "https://localhost:1234/foo", MakeAbsoluteAssetURL("https://localhost:1234/", "/foo"))
assert.Equal(t, "https://localhost:1234/foo", MakeAbsoluteAssetURL("https://localhost:1234/", "/foo/"))
assert.Equal(t, "https://localhost:1234/foo/bar", MakeAbsoluteAssetURL("https://localhost:1234/foo", "/bar"))
assert.Equal(t, "https://localhost:1234/foo/bar", MakeAbsoluteAssetURL("https://localhost:1234/foo/", "/bar"))
assert.Equal(t, "https://localhost:1234/foo/bar", MakeAbsoluteAssetURL("https://localhost:1234/foo/", "/bar/"))
assert.Equal(t, "https://localhost:1234/foo", MakeAbsoluteAssetURL("https://localhost:1234/foo", "/foo"))
assert.Equal(t, "https://localhost:1234/foo", MakeAbsoluteAssetURL("https://localhost:1234/foo/", "/foo"))
assert.Equal(t, "https://localhost:1234/foo", MakeAbsoluteAssetURL("https://localhost:1234/foo/", "/foo/"))
assert.Equal(t, "https://localhost:1234/bar", MakeAbsoluteAssetURL("https://localhost:1234/foo", "/bar"))
assert.Equal(t, "https://localhost:1234/bar", MakeAbsoluteAssetURL("https://localhost:1234/foo/", "/bar"))
assert.Equal(t, "https://localhost:1234/bar", MakeAbsoluteAssetURL("https://localhost:1234/foo/", "/bar/"))
}

func TestMakeManifestData(t *testing.T) {


Loading…
Cancel
Save