MCPcopy Index your code
hub / github.com/gogs/gogs / Clean

Function Clean

internal/pathutil/pathutil.go:13–16  ·  view source on GitHub ↗

Clean cleans up given path and returns a relative path that goes straight down to prevent path traversal. 🚨 SECURITY: This function MUST be used for any user input that is used as file system path to prevent path traversal.

(p string)

Source from the content-addressed store, hash-verified

11// 🚨 SECURITY: This function MUST be used for any user input that is used as
12// file system path to prevent path traversal.
13func Clean(p string) string {
14 p = strings.ReplaceAll(p, `\`, "/")
15 return strings.Trim(path.Clean("/"+p), "/")
16}

Callers 13

ToWikiPageNameFunction · 0.92
NewUploadFunction · 0.92
UploadRepoFilesMethod · 0.92
UserPathFunction · 0.92
RepositoryPathFunction · 0.92
HTTPFunction · 0.92
editFilePostFunction · 0.92
DiffPreviewPostFunction · 0.92
DeleteFilePostFunction · 0.92
UploadFilePostFunction · 0.92
GetContentsFunction · 0.92
PutContentsFunction · 0.92

Calls 1

ReplaceAllMethod · 0.80

Tested by 1

TestCleanFunction · 0.68