aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/securitypolicies_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2021-12-16 11:09:21 +0100
committerBjørn Erik Pedersen <[email protected]>2021-12-17 09:33:51 +0100
commit22ef5da20d1685dfe6aff3bd9364c9b1f1d0d8f8 (patch)
treeffa7339b033795291dafdd9b1bc3f23b64f55d38 /hugolib/securitypolicies_test.go
parent5758c370eac6c4460cd6bb34d4475c8d347585f6 (diff)
downloadhugo-22ef5da20d1685dfe6aff3bd9364c9b1f1d0d8f8.tar.gz
hugo-22ef5da20d1685dfe6aff3bd9364c9b1f1d0d8f8.zip
Add resources.GetRemote
In Hugo 0.89 we added remote support to `resources.Get`. In hindsight that was not a great idea, as a poll from many Hugo users showed. See Issue #9285 for more details. After this commit `resources.Get` only supports local resource lookups. If you want to support both, you need to use a construct similar to: Also improve some option case handling. ``` {{ resource := "" }} {{ if (urls.Parse $url).IsAbs }} {{ $resource = resources.GetRemote $url }} {{ else }} {{ $resource = resources.Get $url }} {{ end }} ``` Fixes #9285 Fixes #9296
Diffstat (limited to 'hugolib/securitypolicies_test.go')
-rw-r--r--hugolib/securitypolicies_test.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/hugolib/securitypolicies_test.go b/hugolib/securitypolicies_test.go
index 297f49479..aa062bb1f 100644
--- a/hugolib/securitypolicies_test.go
+++ b/hugolib/securitypolicies_test.go
@@ -148,19 +148,19 @@ func TestSecurityPolicies(t *testing.T) {
testVariant(c, cb, `(?s).*"dart-sass-embedded" is not whitelisted in policy "security\.exec\.allow".*`)
})
- c.Run("resources.Get, OK", func(c *qt.C) {
+ c.Run("resources.GetRemote, OK", func(c *qt.C) {
c.Parallel()
- httpTestVariant(c, `{{ $json := resources.Get "%[1]s/fruits.json" }}{{ $json.Content }}`, "", nil)
+ httpTestVariant(c, `{{ $json := resources.GetRemote "%[1]s/fruits.json" }}{{ $json.Content }}`, "", nil)
})
- c.Run("resources.Get, denied method", func(c *qt.C) {
+ c.Run("resources.GetRemote, denied method", func(c *qt.C) {
c.Parallel()
- httpTestVariant(c, `{{ $json := resources.Get "%[1]s/fruits.json" (dict "method" "DELETE" ) }}{{ $json.Content }}`, `(?s).*"DELETE" is not whitelisted in policy "security\.http\.method".*`, nil)
+ httpTestVariant(c, `{{ $json := resources.GetRemote "%[1]s/fruits.json" (dict "method" "DELETE" ) }}{{ $json.Content }}`, `(?s).*"DELETE" is not whitelisted in policy "security\.http\.method".*`, nil)
})
- c.Run("resources.Get, denied URL", func(c *qt.C) {
+ c.Run("resources.GetRemote, denied URL", func(c *qt.C) {
c.Parallel()
- httpTestVariant(c, `{{ $json := resources.Get "%[1]s/fruits.json" }}{{ $json.Content }}`, `(?s).*is not whitelisted in policy "security\.http\.urls".*`,
+ httpTestVariant(c, `{{ $json := resources.GetRemote "%[1]s/fruits.json" }}{{ $json.Content }}`, `(?s).*is not whitelisted in policy "security\.http\.urls".*`,
func(b *sitesBuilder) {
b.WithConfigFile("toml", `
[security]