fixed some issues with jid escaping
This commit is contained in:
parent
b2a9c63568
commit
72388e37f5
|
@ -58,14 +58,14 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher {
|
|||
mRandom = new SecureRandom();
|
||||
Button next = findViewById(R.id.create_account);
|
||||
next.setOnClickListener(v -> {
|
||||
try {
|
||||
String username = mUsername.getText().toString();
|
||||
if (username.contains("@") || username.length() < 3) {
|
||||
Jid jid = Jid.of(username.toLowerCase(), Config.MAGIC_CREATE_DOMAIN, null);
|
||||
if (!jid.getEscapedLocal().equals(jid.getLocal())|| username.length() < 3) {
|
||||
mUsername.setError(getString(R.string.invalid_username));
|
||||
mUsername.requestFocus();
|
||||
} else {
|
||||
mUsername.setError(null);
|
||||
try {
|
||||
Jid jid = Jid.of(username.toLowerCase(), Config.MAGIC_CREATE_DOMAIN, null);
|
||||
Account account = xmppConnectionService.findAccountByJid(jid);
|
||||
if (account == null) {
|
||||
account = new Account(jid, createPassword());
|
||||
|
@ -81,11 +81,11 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher {
|
|||
Toast.makeText(MagicCreateActivity.this, R.string.secure_password_generated, Toast.LENGTH_SHORT).show();
|
||||
WelcomeActivity.addInviteUri(intent, getIntent());
|
||||
startActivity(intent);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
mUsername.setError(getString(R.string.invalid_username));
|
||||
mUsername.requestFocus();
|
||||
}
|
||||
}
|
||||
});
|
||||
mUsername.addTextChangedListener(this);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher {
|
|||
try {
|
||||
mFullJidDisplay.setVisibility(View.VISIBLE);
|
||||
Jid jid = Jid.of(s.toString().toLowerCase(), Config.MAGIC_CREATE_DOMAIN, null);
|
||||
mFullJidDisplay.setText(getString(R.string.your_full_jid_will_be, jid.toString()));
|
||||
mFullJidDisplay.setText(getString(R.string.your_full_jid_will_be, jid.toEscapedString()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
mFullJidDisplay.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
|
|
@ -369,7 +369,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||
Bookmark bookmark = (Bookmark) conferences.get(position);
|
||||
Intent shareIntent = new Intent();
|
||||
shareIntent.setAction(Intent.ACTION_SEND);
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, "xmpp:" + bookmark.getJid().asBareJid().toString() + "?join");
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, "xmpp:" + bookmark.getJid().asBareJid().toEscapedString() + "?join");
|
||||
shareIntent.setType("text/plain");
|
||||
try {
|
||||
startActivity(Intent.createChooser(shareIntent, getText(R.string.share_uri_with)));
|
||||
|
|
|
@ -151,9 +151,8 @@ public class Element {
|
|||
final String jid = this.getAttribute(name);
|
||||
if (jid != null && !jid.isEmpty()) {
|
||||
try {
|
||||
return Jid.of(jid);
|
||||
return Jid.ofEscaped(jid);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
Log.e(Config.LOGTAG, "could not parse jid " + jid);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1020,7 +1020,7 @@ public class XmppConnection implements Runnable {
|
|||
final Element jid = bind.findChild("jid");
|
||||
if (jid != null && jid.getContent() != null) {
|
||||
try {
|
||||
Jid assignedJid = Jid.of(jid.getContent());
|
||||
Jid assignedJid = Jid.ofEscaped(jid.getContent());
|
||||
if (!account.getJid().getDomain().equals(assignedJid.getDomain())) {
|
||||
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": server tried to re-assign domain to "+assignedJid.getDomain());
|
||||
throw new StateChangingError(Account.State.BIND_FAILURE);
|
||||
|
|
Loading…
Reference in a new issue