Make legacy sendxmpp config handling more robust.

This commit is contained in:
Martin Dosch 2024-07-10 20:35:07 +02:00
parent 96706aa802
commit 448f2da012
No known key found for this signature in database
GPG Key ID: 52A57CFCE13D657D

View File

@ -123,18 +123,22 @@ func parseConfig(configPath string) (configuration, error) {
output.alias = column[1]
default:
// Try to parse legacy sendxmpp config files.
if strings.Contains(scanner.Text(), ";") {
output.username = strings.Split(column[0], ";")[0]
output.jserver = strings.Split(column[0], ";")[1]
output.password = column[1]
} else {
output.username = strings.Split(column[0], ":")[0]
jserver := strings.Split(column[0], "@")[1]
if len(jserver) < defaultLenServerConf {
log.Fatal("Couldn't parse config: ", column[0])
if len(column) >= defaultConfigColumnSep {
if strings.Contains(scanner.Text(), ";") {
output.username = strings.Split(column[0], ";")[0]
output.jserver = strings.Split(column[0], ";")[1]
output.password = column[1]
} else {
output.username = strings.Split(column[0], ":")[0]
if strings.Contains(output.username, "@") {
jserver := strings.SplitAfter(output.username, "@")[1]
if len(jserver) < defaultLenServerConf {
log.Fatal("Couldn't parse config: ", column[0])
}
output.jserver = jserver
}
output.password = column[1]
}
output.jserver = jserver
output.password = column[1]
}
}
}