MCPcopy
hub / github.com/caddyserver/caddy / TestSanitizedPathJoin

Function TestSanitizedPathJoin

modules/caddyhttp/caddyhttp_test.go:10–148  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestSanitizedPathJoin(t *testing.T) {
11 // For reference:
12 // %2e = .
13 // %2f = /
14 // %5c = \
15 for i, tc := range []struct {
16 inputRoot string
17 inputPath string
18 expect string
19 expectWindows string
20 }{
21 {
22 inputPath: "",
23 expect: ".",
24 },
25 {
26 inputPath: "/",
27 expect: ".",
28 },
29 {
30 // fileserver.MatchFile passes an inputPath of "//" for some try_files values.
31 // See https://github.com/caddyserver/caddy/issues/6352
32 inputPath: "//",
33 expect: filepath.FromSlash("./"),
34 },
35 {
36 inputPath: "/foo",
37 expect: "foo",
38 },
39 {
40 inputPath: "/foo/",
41 expect: filepath.FromSlash("foo/"),
42 },
43 {
44 inputPath: "/foo/bar",
45 expect: filepath.FromSlash("foo/bar"),
46 },
47 {
48 inputRoot: "/a",
49 inputPath: "/foo/bar",
50 expect: filepath.FromSlash("/a/foo/bar"),
51 },
52 {
53 inputPath: "/foo/../bar",
54 expect: "bar",
55 },
56 {
57 inputRoot: "/a/b",
58 inputPath: "/foo/../bar",
59 expect: filepath.FromSlash("/a/b/bar"),
60 },
61 {
62 inputRoot: "/a/b",
63 inputPath: "/..%2fbar",
64 expect: filepath.FromSlash("/a/b/bar"),
65 },
66 {
67 inputRoot: "/a/b",

Callers

nothing calls this directly

Calls 1

SanitizedPathJoinFunction · 0.85

Tested by

no test coverage detected