fix(platform): support Windows storage and native filesystem boundaries
This commit is contained in:
1 parent
3726423338
commit
e239fff253
24 files changed
+355
-51
No files matched your search
@@ -0,0 +1,30 @@
|
||||
package fileutil
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// IsLocalPath also rejects Windows aliases and invalid native filename characters.
|
||||
func IsLocalPath(name string) bool {
|
||||
if !filepath.IsLocal(name) {
|
||||
return false
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
if strings.ContainsAny(name, `<>:"\|?*`) {
|
||||
return false
|
||||
}
|
||||
for _, c := range name {
|
||||
if c < 32 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
for _, part := range strings.Split(name, "/") {
|
||||
if strings.HasSuffix(part, " ") || strings.HasSuffix(part, ".") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
Reference in new issue
Block a user