aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-04-07 23:36:33 +0200
committerChristian Schneppe <christian@pix-art.de>2018-04-07 23:36:33 +0200
commitc58c0ad34778588f1631ea409b507c3725f2d4c9 (patch)
tree647322090f00a2e504aa35579cdf2b782b61484d /src
parent2545982aae8830b652f64c625babbc49d94538e5 (diff)
fixed some issues with jid escaping
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java b/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java
index 91c527ca1..8c758be6d 100644
--- a/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java
@@ -58,14 +58,14 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher {
mRandom = new SecureRandom();
Button next = findViewById(R.id.create_account);
next.setOnClickListener(v -> {
- String username = mUsername.getText().toString();
- if (username.contains("@") || 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);
+ try {
+ String username = mUsername.getText().toString();
+ 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);
Account account = xmppConnectionService.findAccountByJid(jid);
if (account == null) {
account = new Account(jid, createPassword());
@@ -81,10 +81,10 @@ 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();
}
+ } 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);
}