Make legacy sendxmpp config handling more robust.

v0.11
Martin Dosch 3 months ago
parent 96706aa802
commit 448f2da012
No known key found for this signature in database
GPG Key ID: 52A57CFCE13D657D

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

Loading…
Cancel
Save