aboutsummaryrefslogtreecommitdiff
path: root/src/path/example_test.go
AgeCommit message (Collapse)Author
2025-11-25path: add more examples for path.CleanLouis Nyffenegger
Clarify that the function path.Clean only normalises paths and does not protect against directory-traversal attacks. Change-Id: I66f1267ac15900ac0cb6011ace0c79aabaebc68b GitHub-Last-Rev: d669e1edf6221e7c8e0a9aa7bf46493c8ea85ba0 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>
2020-08-19path,path/filepath: add Join examples with ".." componentsAndrew Ekstedt
People sometimes expect Join to trim .. components from its arguments before joining, and are surprised that it doesn't. This is bad if they were relying on that assumed behaviour to prevent directory traversal attacks. While a careful reading of the documentation for Join and Clean might dispel this notion, it is not obvious at first glance. Add a case to the examples to nudge people in the right direction. Updates #40373 Change-Id: Ib5792c12ba1000811a0c0eb77048196d0b26da60 Reviewed-on: https://go-review.googlesource.com/c/go/+/249177 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2019-09-01path: change the output format of ExampleSplit functionIrbe Krumina
At the moment the last output line of ExampleSplit- two empty strings- are being trimmed from the output. I have formatted the output of the function to avoid whitespace trimming and show empty strings more clearly. Fixes #23542 Change-Id: Ic2a4d98cfa06db1466c6c6d98099542df9e7c88b Reviewed-on: https://go-review.googlesource.com/c/go/+/191397 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2018-02-13path: add example for MatchJeff Dupont
Change-Id: I5ab475011e9200c5055809e658d14c04c0a07a8a Reviewed-on: https://go-review.googlesource.com/51413 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-09-08path: add path.Dir example with trailing slashMayank Kumar
Change-Id: I143203a9dcf9a4da0e53a3aab6e370244b849296 Reviewed-on: https://go-review.googlesource.com/62270 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-16path: add examplesMark Harrison
This change adds several examples, with emphasis on special or edge cases such as a directory parameter consisting of an empty string. Change-Id: Ib4ac3d0f6d503493eeed0c4fda7c12acf782e9e2 Reviewed-on: https://go-review.googlesource.com/43010 Reviewed-by: Steve Francia <spf@golang.org> Run-TryBot: Jaana Burcu Dogan <jbd@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-03path, path/filepath: add Join example with joined rooted pathRuss Cox
This makes clear that Go's path.Join and filepath.Join are different from the Python os.path.join (and perhaps others). Requested in private mail. Change-Id: Ie5dfad8a57f9baa5cca31246af1fd4dd5b1a64ee Reviewed-on: https://go-review.googlesource.com/20711 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.