From c96c36f64df98fd939d3ecc594579b7e5552c313 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Tue, 14 Oct 2025 16:09:55 +1100 Subject: [PATCH] chore: defer to go-trustless-utils for filename check --- go.mod | 2 +- go.sum | 4 ++-- httpipfs.go | 18 ++++-------------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index 5b85347..2122500 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/ipld/go-codec-dagpb v1.7.0 github.com/ipld/go-fixtureplate v0.1.0 github.com/ipld/go-ipld-prime v0.21.0 - github.com/ipld/go-trustless-utils v0.6.0 + github.com/ipld/go-trustless-utils v0.7.0 github.com/ipld/ipld/specs v0.0.0-20231012031213-54d3b21deda4 github.com/ipni/go-libipni v0.7.1 github.com/ipni/index-provider v0.15.5 diff --git a/go.sum b/go.sum index 44498ef..bba028b 100644 --- a/go.sum +++ b/go.sum @@ -210,8 +210,8 @@ github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ= github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20250821084354-a425e60cd714 h1:cqNk8PEwHnK0vqWln+U/YZhQc9h2NB3KjUjDPZo5Q2s= github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20250821084354-a425e60cd714/go.mod h1:ZEUdra3CoqRVRYgAX/jAJO9aZGz6SKtKEG628fHHktY= -github.com/ipld/go-trustless-utils v0.6.0 h1:Yy9L+HI2AQwlq5EQPr3ZyAKbkBz/BpojqGAvym0s2lA= -github.com/ipld/go-trustless-utils v0.6.0/go.mod h1:inKRRT3L9BT1r/u6yBbXuIq+wIGO2yf0NqiOo36bH9U= +github.com/ipld/go-trustless-utils v0.7.0 h1:iKFR4f9MdPw/cM0AMz7Ss+QGyTh5RylCAjOEd4VqPXE= +github.com/ipld/go-trustless-utils v0.7.0/go.mod h1:inKRRT3L9BT1r/u6yBbXuIq+wIGO2yf0NqiOo36bH9U= github.com/ipld/ipld/specs v0.0.0-20231012031213-54d3b21deda4 h1:0VXv637/xpI0Pb5J8K+K8iRtTw4DOcxs0MB1HMzfwNY= github.com/ipld/ipld/specs v0.0.0-20231012031213-54d3b21deda4/go.mod h1:WcT0DfRe+e2QFY0kcbsOnuT6jL5Q0JNZ83I5DHIdStg= github.com/ipni/go-libipni v0.7.1 h1:0peyJTXXgrDHqjiqpSuYlxH3JIvnUMw1Orq7nJtq/tY= diff --git a/httpipfs.go b/httpipfs.go index be1597d..ee46da1 100644 --- a/httpipfs.go +++ b/httpipfs.go @@ -255,21 +255,11 @@ func NewHttpIpfsHandlerFunc( } accept := accepts[0] - // Parse filename parameter - trustlesshttp.ParseFilename only accepts .car - // but frisbii also supports raw responses with .bin, so we handle that case - fileName, err := trustlesshttp.ParseFilename(req) + // Parse filename parameter - supports both .car and .bin extensions + fileName, err := trustlesshttp.ParseFilename(req, accepts) if err != nil { - // If ParseFilename failed, check if it's because of .bin extension for raw response - if accept.IsRaw() && req.URL.Query().Get("filename") != "" { - fileName = req.URL.Query().Get("filename") - if !strings.HasSuffix(fileName, ".bin") { - logError(http.StatusBadRequest, fmt.Errorf("invalid filename parameter for raw response; expected .bin extension")) - return - } - } else { - logError(http.StatusBadRequest, err) - return - } + logError(http.StatusBadRequest, err) + return } // validate CID path parameter