Skip to content

Commit 2ee2c46

Browse files
committed
Plan 9 support
Since Plan 9 does not have symlinks, these problems do not occur. Therefore, SecureJoinVFS and SecureJoin can map to filepath.Join. Signed-off-by: Ronald G Minnich <[email protected]>
1 parent 54b1a62 commit 2ee2c46

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

join.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Use of this source code is governed by a BSD-style
44
// license that can be found in the LICENSE file.
55

6+
//go:build !plan9
7+
68
package securejoin
79

810
import (

join_plan9.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (C) 2014-2015 Docker Inc & Go Authors. All rights reserved.
2+
// Copyright (C) 2017-2025 SUSE LLC. All rights reserved.
3+
// Use of this source code is governed by a BSD-style
4+
// license that can be found in the LICENSE file.
5+
6+
package securejoin
7+
8+
import "path/filepath"
9+
10+
// SecureJoin is equivalent to filepath.Join, as plan9 doesn't have symlinks.
11+
func SecureJoin(root, unsafePath string) (string, error) {
12+
unsafePath = filepath.Join(string(filepath.Separator), unsafePath)
13+
return filepath.Join(root, unsafePath), nil
14+
}
15+
16+
// SecureJoinVFS is equivalent to filepath.Join, as plan9 doesn't have symlinks.
17+
func SecureJoinVFS(root, unsafePath string, _ VFS) (string, error) {
18+
return SecureJoin(root, unsafePath)
19+
}

join_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !plan9
6+
57
package securejoin
68

79
import (

0 commit comments

Comments
 (0)