From 6d0bf438e302afcb0db5422ea2da59d1995e08c1 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Wed, 9 Nov 2022 17:49:44 -0800 Subject: path/filepath: add IsLocal IsLocal reports whether a path lexically refers to a location contained within the directory in which it is evaluated. It identifies paths that are absolute, escape a directory with ".." elements, and (on Windows) paths that reference reserved device names. For #56219. Change-Id: I35edfa3ce77b40b8e66f1fc8e0ff73cfd06f2313 Reviewed-on: https://go-review.googlesource.com/c/go/+/449239 Run-TryBot: Damien Neil Reviewed-by: Joseph Tsai TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Reviewed-by: Joedian Reid --- src/path/filepath/path_plan9.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/path/filepath/path_plan9.go') diff --git a/src/path/filepath/path_plan9.go b/src/path/filepath/path_plan9.go index ec792fc831..453206aee3 100644 --- a/src/path/filepath/path_plan9.go +++ b/src/path/filepath/path_plan9.go @@ -6,6 +6,10 @@ package filepath import "strings" +func isLocal(path string) bool { + return unixIsLocal(path) +} + // IsAbs reports whether the path is absolute. func IsAbs(path string) bool { return strings.HasPrefix(path, "/") || strings.HasPrefix(path, "#") -- cgit v1.3-5-g9baa