1
0
mirror of https://github.com/golang/go synced 2024-11-27 00:11:19 -07:00

path/filepath: deprecate HasPrefix

Use the new "Deprecated:" syntax for all instances of HasPrefix.
This is a follow-up to http://golang.org/cl/28413 which only modified path_unix.go.

In this CL, we avoid mentioning that strings.HasPrefix should be used since
that function is still subtly wrong in security applications.

See http://golang.org/cl/5712045 for more information.

Fixes #18355

Change-Id: I0d0306152cd0b0ea5110774c2c78117515b9f5cd
Reviewed-on: https://go-review.googlesource.com/34554
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Joe Tsai 2016-12-16 13:35:51 -08:00 committed by Joe Tsai
parent 61db2e4efa
commit 1106512db5
3 changed files with 8 additions and 1 deletions

View File

@ -18,6 +18,9 @@ func volumeNameLen(path string) int {
}
// HasPrefix exists for historical compatibility and should not be used.
//
// Deprecated: HasPrefix does not respect path boundaries and
// does not ignore case when required.
func HasPrefix(p, prefix string) bool {
return strings.HasPrefix(p, prefix)
}

View File

@ -21,7 +21,8 @@ func volumeNameLen(path string) int {
// HasPrefix exists for historical compatibility and should not be used.
//
// Deprecated: Use strings.HasPrefix instead.
// Deprecated: HasPrefix does not respect path boundaries and
// does not ignore case when required.
func HasPrefix(p, prefix string) bool {
return strings.HasPrefix(p, prefix)
}

View File

@ -65,6 +65,9 @@ func volumeNameLen(path string) int {
}
// HasPrefix exists for historical compatibility and should not be used.
//
// Deprecated: HasPrefix does not respect path boundaries and
// does not ignore case when required.
func HasPrefix(p, prefix string) bool {
if strings.HasPrefix(p, prefix) {
return true