aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2023-05-20 17:37:04 +0200
committerBjørn Erik Pedersen <[email protected]>2023-05-20 20:16:45 +0200
commit2637b4ef4dbb3f8d3e537f900bdd072b4078c87e (patch)
tree6b64225d157397befe5a7d0ab7925b8ad0e6ba94 /resources
parent7c7baa618325cb3d2b1ef48bdc1f97aae25f62e9 (diff)
downloadhugo-2637b4ef4dbb3f8d3e537f900bdd072b4078c87e.tar.gz
hugo-2637b4ef4dbb3f8d3e537f900bdd072b4078c87e.zip
Allow whitelisting mediaTypes used in resources.GetRemote
Fixes #10286
Diffstat (limited to 'resources')
-rw-r--r--resources/resource_factories/create/remote.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/resources/resource_factories/create/remote.go b/resources/resource_factories/create/remote.go
index 3aae57e8d..73171e570 100644
--- a/resources/resource_factories/create/remote.go
+++ b/resources/resource_factories/create/remote.go
@@ -171,10 +171,17 @@ func (c *Client) FromRemote(uri string, optionsm map[string]any) (resource.Resou
contentType := res.Header.Get("Content-Type")
- if isHeadMethod {
- // We have no body to work with, so we need to use the Content-Type header.
- mediaType, _ = media.FromString(contentType)
- } else {
+ // For HEAD requests we have no body to work with, so we need to use the Content-Type header.
+ if isHeadMethod || c.rs.ExecHelper.Sec().HTTP.MediaTypes.Accept(contentType) {
+ var found bool
+ mediaType, found = c.rs.MediaTypes().GetByType(contentType)
+ if !found {
+ // A media type not configured in Hugo, just create one from the content type string.
+ mediaType, _ = media.FromString(contentType)
+ }
+ }
+
+ if mediaType.IsZero() {
var extensionHints []string