{"id":21928095,"url":"https://github.com/depp/safepath","last_synced_at":"2025-06-29T05:33:53.680Z","repository":{"id":57576815,"uuid":"358377910","full_name":"depp/safepath","owner":"depp","description":"Go library which checks that file paths are safe to use","archived":false,"fork":false,"pushed_at":"2021-04-16T02:56:22.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-22T12:18:44.955Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/depp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-15T19:59:59.000Z","updated_at":"2021-04-16T02:56:24.000Z","dependencies_parsed_at":"2022-08-28T20:30:10.842Z","dependency_job_id":null,"html_url":"https://github.com/depp/safepath","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/depp/safepath","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fsafepath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fsafepath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fsafepath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fsafepath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/depp","download_url":"https://codeload.github.com/depp/safepath/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fsafepath/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262543863,"owners_count":23326626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T22:20:41.481Z","updated_at":"2025-06-29T05:33:53.655Z","avatar_url":"https://github.com/depp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SafePath: Path Sanitizing\n\nSafePath checks that pathnames are safe for use.\n\n## Installation\n\nSafePath can be installed with the `go get` command.\n\n```shell\ngo get github.com/depp/safepath\n```\n\n## Usage\n\n```go\nimport \"github.com/depp/safepath\"\n```\n\nTo check if a filename, choose a combination of `Rules` flags and call the `CheckPathSegment()` function. For example, the `URLUnescaped` rule rejects any path which would require percent-encoding when used in a URL.\n\n```go\nrules := safepath.URLUnescaped\nfilename := \"my_file.txt\"\nif err := rules.CheckPathSegment(filename); err != nil {\n    return err\n}\n```\n\nRelative paths can be checked with the `CheckPath()` function. Note that this function only recognizes the path separator /, it does not recognize \\\\.\n\n```go\nrules := safepath.URLUnescaped\nfilepath := \"directory/my_file.txt\"\nif err := rules.CheckPathSegment(filepath); err != nil {\n    return err\n}\n```\n\nError messages from this library are descriptive. Some examples:\n\n```\nError: invalid path \"/\": path is absolute\nError: invalid path segment \"NUL.TXT\": uses reserved Windows filename \"nul\"\n```\n\n## Unicode\n\nThe notion of “safe” in Unicode is a bit difficult to define. This library does not have a comprehensive notion of safety for non-ASCII characters. Currently, there are only two rules that affect non-ASCII characters: `ValidUTF8` and `ASCIIOnly`.\n\n## License\n\nSafePath is provided under the MIT license. See LICENSE.txt for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepp%2Fsafepath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdepp%2Fsafepath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepp%2Fsafepath/lists"}