Test_SanitizePath_Error() — fiber Function Reference
Architecture documentation for the Test_SanitizePath_Error() function in static_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 797c16fa_377f_5a0c_0ded_e6cecd00ede2["Test_SanitizePath_Error()"] f26a2d79_1e01_f027_82eb_45c4308747e8["static_test.go"] 797c16fa_377f_5a0c_0ded_e6cecd00ede2 -->|defined in| f26a2d79_1e01_f027_82eb_45c4308747e8 style 797c16fa_377f_5a0c_0ded_e6cecd00ede2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/static/static_test.go lines 1197–1232
func Test_SanitizePath_Error(t *testing.T) {
t.Parallel()
type testCase struct {
filesystem fs.FS
name string
input []byte
}
testCases := []testCase{
{name: "null byte", input: []byte("/foo/bar.txt%00")},
{name: "encoded backslash traversal", input: []byte("/foo%5C..%5Cbar.txt")},
{name: "double encoded backslash traversal", input: []byte("/%255C..%255C..%255CWindows%255Cwin.ini")},
{name: "encoded backslash absolute", input: []byte("/%5CWindows%5CSystem32%5Cdrivers%5Cetc%5Chosts")},
{name: "double encoded backslash absolute", input: []byte("/%255CWindows%255CSystem32%255Cdrivers%255Cetc%255Chosts")},
{name: "encoded backslash mixed slashes", input: []byte("/..%5C..%5Cetc%5Cpasswd")},
{name: "encoded backslash mixed encoding", input: []byte("/%2e%2e%5c%2e%2e%5cetc%5cpasswd")},
{name: "encoded backslash with encoded slash", input: []byte("/%2e%2e%2f%2e%2e%5cetc%5cpasswd")},
{name: "encoded backslash unc path", input: []byte("//server%5Cshare%5Csecret.txt")},
{name: "encoded backslash drive letter", input: []byte("/C:%5CWindows%5CSystem32%5Ccmd.exe")},
{name: "double slash path", input: []byte("//foo//bar.txt")},
{name: "drive letter", input: []byte("C:/Windows/System32/cmd.exe")},
{name: "drive letter with leading slash", input: []byte("/C:/Windows/System32/cmd.exe")},
{name: "encoded drive letter", input: []byte("/%43:%5CWindows%5CSystem32%5Ccmd.exe")},
{name: "unc path", input: []byte("//server/share/secret.txt")},
{name: "encoded unc path", input: []byte("/%2F%2Fserver%2Fshare%2Fsecret.txt")},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
_, err := sanitizePath(tc.input, tc.filesystem)
require.ErrorIs(t, err, ErrInvalidPath, "Expected ErrInvalidPath for input: %s", tc.input)
})
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_SanitizePath_Error() do?
Test_SanitizePath_Error() is a function in the fiber codebase, defined in middleware/static/static_test.go.
Where is Test_SanitizePath_Error() defined?
Test_SanitizePath_Error() is defined in middleware/static/static_test.go at line 1197.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free