fix: correct field mapping in forms and prevent double -o prefix in SSH options

This commit is contained in:
2026-01-04 20:44:01 +01:00
parent 2f9587c8c8
commit def2b4fa8d
4 changed files with 39 additions and 13 deletions

View File

@@ -658,13 +658,34 @@ func AddSSHHostToFile(host SSHHost, configPath string) error {
}
// ParseSSHOptionsFromCommand converts SSH command line options to config format
// Input: "-o Compression=yes -o ServerAliveInterval=60"
// Input: "-o Compression=yes -o ServerAliveInterval=60" or "ForwardX11 true" or "Compression yes"
// Output: "Compression yes\nServerAliveInterval 60"
func ParseSSHOptionsFromCommand(options string) string {
if options == "" {
return ""
}
options = strings.TrimSpace(options)
// If it doesn't contain -o, assume it's already in config format
if !strings.Contains(options, "-o") {
// Just normalize spaces and ensure newlines between options
lines := strings.Split(options, "\n")
var result []string
for _, line := range lines {
line = strings.TrimSpace(line)
if line == "" {
continue
}
// Normalize spacing (replace multiple spaces with single space)
parts := strings.Fields(line)
if len(parts) > 0 {
result = append(result, strings.Join(parts, " "))
}
}
return strings.Join(result, "\n")
}
var result []string
parts := strings.Split(options, "-o")
@@ -690,6 +711,12 @@ func FormatSSHOptionsForCommand(options string) string {
return ""
}
// If already in command format (starts with -o), return as is
trimmed := strings.TrimSpace(options)
if strings.HasPrefix(trimmed, "-o ") {
return trimmed
}
var result []string
lines := strings.Split(options, "\n")