mirror of
https://salsa.debian.org/mdosch/go-sendxmpp
synced 2024-11-17 03:25:33 +00:00
Make legacy sendxmpp config handling more robust.
This commit is contained in:
parent
96706aa802
commit
448f2da012
@ -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]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user