check domain name against DNSName to avoid rare crashes

This commit is contained in:
Daniel Gultsch 2022-04-08 15:54:53 +02:00
parent ec02e8a198
commit bf8afe0396
2 changed files with 6 additions and 0 deletions

View file

@ -208,6 +208,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
jid = Jid.ofEscaped(binding.accountJid.getText().toString(), getUserModeDomain(), null);
} else {
jid = Jid.ofEscaped(binding.accountJid.getText().toString());
Resolver.checkDomain(jid);
}
} catch (final NullPointerException | IllegalArgumentException e) {
if (mUsernameMode) {

View file

@ -37,6 +37,7 @@ import de.measite.minidns.record.SRV;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.xmpp.Jid;
public class Resolver {
@ -84,6 +85,10 @@ public class Resolver {
return Collections.singletonList(result);
}
public static void checkDomain(final Jid jid) {
DNSName.from(jid.getDomain());
}
public static boolean invalidHostname(final String hostname) {
try {
DNSName.from(hostname);