mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-09-19 17:50:12 +00:00
fix(agentcompat): classify Windows absolute paths
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
This commit is contained in:
@@ -90,6 +90,9 @@ func validateRelativeAgentPath(candidate string, destructive bool) (string, erro
|
||||
if strings.TrimSpace(candidate) == "" {
|
||||
return "", rejectPath(PathRejectionEmpty)
|
||||
}
|
||||
if hasWindowsAbsolutePath(candidate) {
|
||||
return "", rejectPath(PathRejectionAbsolute)
|
||||
}
|
||||
if hasWindowsVolume(candidate) {
|
||||
return "", rejectPath(PathRejectionVolume)
|
||||
}
|
||||
@@ -118,6 +121,10 @@ func validateRelativeAgentPath(candidate string, destructive bool) (string, erro
|
||||
return nativeRelative, nil
|
||||
}
|
||||
|
||||
func hasWindowsAbsolutePath(candidate string) bool {
|
||||
return len(candidate) >= 3 && ((candidate[0] >= 'A' && candidate[0] <= 'Z') || (candidate[0] >= 'a' && candidate[0] <= 'z')) && candidate[1] == ':' && (candidate[2] == '\\' || candidate[2] == '/')
|
||||
}
|
||||
|
||||
func hasWindowsVolume(candidate string) bool {
|
||||
if strings.HasPrefix(candidate, `\\`) || strings.HasPrefix(candidate, `//`) {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user