29 lines
707 B
Go
29 lines
707 B
Go
|
|
// Copyright 2025 Patial Tech (Ankit Patial).
|
||
|
|
//
|
||
|
|
// This file is part of code.patial.tech/go/appcore, which is MIT licensed.
|
||
|
|
// See http://opensource.org/licenses/MIT
|
||
|
|
|
||
|
|
package open
|
||
|
|
|
||
|
|
import (
|
||
|
|
"errors"
|
||
|
|
"strings"
|
||
|
|
)
|
||
|
|
|
||
|
|
// validateAppName validates application names on Windows
|
||
|
|
func validateAppName(appName string) error {
|
||
|
|
if appName == "" {
|
||
|
|
return errors.New("application name cannot be empty")
|
||
|
|
}
|
||
|
|
|
||
|
|
// Check for dangerous characters in Windows cmd context
|
||
|
|
dangerous := []string{";", "|", "&", "$", "`", "\n", "\r", "&&", "||", ">", "<", "^"}
|
||
|
|
for _, char := range dangerous {
|
||
|
|
if strings.Contains(appName, char) {
|
||
|
|
return errors.New("application name contains invalid characters")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|