IsInitScriptPath tries to determine if the input string is a path to a script rather than an inline script content.
(input string)
| 209 | // IsInitScriptPath tries to determine if the input string is a path to a script |
| 210 | // rather than an inline script content. |
| 211 | func IsInitScriptPath(input string) bool { |
| 212 | if len(input) == 0 || strings.Contains(input, "\n") { |
| 213 | return false |
| 214 | } |
| 215 | |
| 216 | if suspiciousPattern.MatchString(input) { |
| 217 | return false |
| 218 | } |
| 219 | |
| 220 | if flagPattern.MatchString(input) { |
| 221 | return false |
| 222 | } |
| 223 | |
| 224 | // Check for home directory path |
| 225 | if strings.HasPrefix(input, "~/") { |
| 226 | return true |
| 227 | } |
| 228 | |
| 229 | // Path must be absolute (if not home directory) |
| 230 | if !filepath.IsAbs(input) { |
| 231 | return false |
| 232 | } |
| 233 | |
| 234 | // Check if path starts with system binary directories |
| 235 | normalizedPath := filepath.ToSlash(input) |
| 236 | for _, binDir := range systemBinDirs { |
| 237 | if strings.HasPrefix(normalizedPath, binDir) { |
| 238 | return false |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | return true |
| 243 | } |
| 244 | |
| 245 | const ( |
| 246 | TempFileSuffix = ".tmp" |
no outgoing calls
no test coverage detected