mirror of
https://github.com/golang/go.git
synced 2026-02-06 18:00:01 +00:00
path: add more examples for path.Clean
Clarify that the function path.Clean only normalises paths and does not
protect against directory-traversal attacks.
Change-Id: I66f1267ac15900ac0cb6011ace0c79aabaebc68b
GitHub-Last-Rev: d669e1edf6
GitHub-Pull-Request: golang/go#74397
Reviewed-on: https://go-review.googlesource.com/c/go/+/684376
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
This commit is contained in:
parent
eec40aae45
commit
a572d571fa
1 changed files with 4 additions and 0 deletions
|
|
@ -25,6 +25,8 @@ func ExampleClean() {
|
|||
"a//c",
|
||||
"a/c/.",
|
||||
"a/c/b/..",
|
||||
"../a/c",
|
||||
"../a/b/../././/c",
|
||||
"/../a/c",
|
||||
"/../a/b/../././/c",
|
||||
"",
|
||||
|
|
@ -39,6 +41,8 @@ func ExampleClean() {
|
|||
// Clean("a//c") = "a/c"
|
||||
// Clean("a/c/.") = "a/c"
|
||||
// Clean("a/c/b/..") = "a/c"
|
||||
// Clean("../a/c") = "../a/c"
|
||||
// Clean("../a/b/../././/c") = "../a/c"
|
||||
// Clean("/../a/c") = "/a/c"
|
||||
// Clean("/../a/b/../././/c") = "/a/c"
|
||||
// Clean("") = "."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue