diff options
author | Joe Tsai <joetsai@digital-static.net> | 2016-12-16 13:35:51 -0800 |
---|---|---|
committer | Joe Tsai <thebrokentoaster@gmail.com> | 2016-12-16 22:30:12 +0000 |
commit | 1106512db54fc2736c7a9a67dd553fc9e1fca742 (patch) | |
tree | d2347ce096ecb6b81ca1121fcc4b8cb443fb83f4 | |
parent | 61db2e4efa2a8f558fd3557958d1c86dbbe7d3cc (diff) | |
download | go-1106512db54fc2736c7a9a67dd553fc9e1fca742.tar.gz go-1106512db54fc2736c7a9a67dd553fc9e1fca742.zip |
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>
-rw-r--r-- | src/path/filepath/path_plan9.go | 3 | ||||
-rw-r--r-- | src/path/filepath/path_unix.go | 3 | ||||
-rw-r--r-- | src/path/filepath/path_windows.go | 3 |
3 files changed, 8 insertions, 1 deletions
diff --git a/src/path/filepath/path_plan9.go b/src/path/filepath/path_plan9.go index 60d46d9d42..ec792fc831 100644 --- a/src/path/filepath/path_plan9.go +++ b/src/path/filepath/path_plan9.go @@ -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) } diff --git a/src/path/filepath/path_unix.go b/src/path/filepath/path_unix.go index dddcac0a5c..d77ff24cdc 100644 --- a/src/path/filepath/path_unix.go +++ b/src/path/filepath/path_unix.go @@ -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) } diff --git a/src/path/filepath/path_windows.go b/src/path/filepath/path_windows.go index 359703de26..0d8b62015c 100644 --- a/src/path/filepath/path_windows.go +++ b/src/path/filepath/path_windows.go @@ -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 |