Test_Ctx_Download_SanitizesFilenameControls() — fiber Function Reference
Architecture documentation for the Test_Ctx_Download_SanitizesFilenameControls() function in ctx_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 4458c250_4096_3742_f7d8_977b22886452["Test_Ctx_Download_SanitizesFilenameControls()"] 7b3d4933_5ae3_f84d_ff6d_0cb34e268026["ctx_test.go"] 4458c250_4096_3742_f7d8_977b22886452 -->|defined in| 7b3d4933_5ae3_f84d_ff6d_0cb34e268026 style 4458c250_4096_3742_f7d8_977b22886452 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
ctx_test.go lines 5113–5156
func Test_Ctx_Download_SanitizesFilenameControls(t *testing.T) {
t.Parallel()
app := New()
testCases := []struct {
name string
filename string
expected string
}{
{
name: "base name only",
filename: "../docs/archive.tar.gz",
expected: `attachment; filename="archive.tar.gz"`,
},
{
name: "controls stripped",
filename: "down\r\nload\t\x00.txt",
expected: `attachment; filename="download.txt"`,
},
{
name: "empty after sanitize",
filename: "\r\n\t\x00",
expected: `attachment; filename="download"`,
},
{
name: "dot fallback",
filename: ".",
expected: `attachment; filename="download"`,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
c := app.AcquireCtx(&fasthttp.RequestCtx{})
require.NoError(t, c.Download("ctx.go", tc.filename))
header := string(c.Response().Header.Peek(HeaderContentDisposition))
require.Equal(t, tc.expected, header)
require.NotContains(t, header, "\r")
require.NotContains(t, header, "\n")
require.NotContains(t, header, "\t")
require.NotContains(t, header, "\x00")
})
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Ctx_Download_SanitizesFilenameControls() do?
Test_Ctx_Download_SanitizesFilenameControls() is a function in the fiber codebase, defined in ctx_test.go.
Where is Test_Ctx_Download_SanitizesFilenameControls() defined?
Test_Ctx_Download_SanitizesFilenameControls() is defined in ctx_test.go at line 5113.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free