From aa1e69d277aabad46e032c71dbd5f65fe9d6e181 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 20 May 2020 20:14:13 +0200 Subject: [PATCH] use escaped jid for EXTRA_ACCOUNT --- .../conversations/ui/ManageAccountActivity.java | 6 +++--- .../services/ChannelDiscoveryService.java | 2 +- .../siacs/conversations/ui/BlocklistActivity.java | 2 +- .../ui/ChooseAccountForProfilePictureActivity.java | 2 +- .../conversations/ui/ChooseContactActivity.java | 6 +++--- .../conversations/ui/ContactDetailsActivity.java | 4 ++-- .../conversations/ui/ConversationFragment.java | 2 +- .../conversations/ui/EditAccountActivity.java | 14 +++++++------- .../siacs/conversations/ui/ShareWithActivity.java | 2 +- .../ui/StartConversationActivity.java | 2 +- .../eu/siacs/conversations/ui/XmppActivity.java | 6 +++--- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java index 86bdd5501..1c127a877 100644 --- a/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java +++ b/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java @@ -85,7 +85,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda String jid = savedInstanceState.getString(STATE_SELECTED_ACCOUNT); if (jid != null) { try { - this.selectedAccountJid = Jid.of(jid); + this.selectedAccountJid = Jid.ofEscaped(jid); } catch (IllegalArgumentException e) { this.selectedAccountJid = null; } @@ -111,7 +111,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda @Override public void onSaveInstanceState(final Bundle savedInstanceState) { if (selectedAccount != null) { - savedInstanceState.putString(STATE_SELECTED_ACCOUNT, selectedAccount.getJid().asBareJid().toString()); + savedInstanceState.putString(STATE_SELECTED_ACCOUNT, selectedAccount.getJid().asBareJid().toEscapedString()); } super.onSaveInstanceState(savedInstanceState); } @@ -286,7 +286,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda private void publishAvatar(Account account) { Intent intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class); - intent.putExtra(EXTRA_ACCOUNT, account.getJid().toString()); + intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString()); startActivity(intent); } diff --git a/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java b/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java index dd390eb1e..19c0085a0 100644 --- a/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java +++ b/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java @@ -222,7 +222,7 @@ public class ChannelDiscoveryService { continue; } for (final String mucService : xmppConnection.getMucServers()) { - Jid jid = Jid.of(mucService); + Jid jid = Jid.ofEscaped(mucService); if (!localMucServices.containsKey(jid)) { localMucServices.put(jid, account); } diff --git a/src/main/java/eu/siacs/conversations/ui/BlocklistActivity.java b/src/main/java/eu/siacs/conversations/ui/BlocklistActivity.java index f0aef4741..201c5e7b7 100644 --- a/src/main/java/eu/siacs/conversations/ui/BlocklistActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/BlocklistActivity.java @@ -35,7 +35,7 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem @Override public void onBackendConnected() { for (final Account account : xmppConnectionService.getAccounts()) { - if (account.getJid().toString().equals(getIntent().getStringExtra(EXTRA_ACCOUNT))) { + if (account.getJid().toEscapedString().equals(getIntent().getStringExtra(EXTRA_ACCOUNT))) { this.account = account; break; } diff --git a/src/main/java/eu/siacs/conversations/ui/ChooseAccountForProfilePictureActivity.java b/src/main/java/eu/siacs/conversations/ui/ChooseAccountForProfilePictureActivity.java index a7e0e5fcb..af1fb7656 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChooseAccountForProfilePictureActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChooseAccountForProfilePictureActivity.java @@ -73,7 +73,7 @@ public class ChooseAccountForProfilePictureActivity extends XmppActivity { final Uri uri = startIntent == null ? null : startIntent.getData(); if (uri != null) { Intent intent = new Intent(this, PublishProfilePictureActivity.class); - intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toString()); + intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString()); intent.setData(uri); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); try { diff --git a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java index afda66709..bdd19a623 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java @@ -75,7 +75,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity im intent.putExtra(EXTRA_CONVERSATION, conversation.getUuid()); intent.putExtra(EXTRA_SELECT_MULTIPLE, true); intent.putExtra(EXTRA_SHOW_ENTER_JID, true); - intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toString()); + intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toEscapedString()); return intent; } @@ -321,7 +321,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity im final Intent request = getIntent(); final Intent data = new Intent(); data.putExtra("contact", contactJid.toString()); - data.putExtra(EXTRA_ACCOUNT, accountJid.toString()); + data.putExtra(EXTRA_ACCOUNT, accountJid.toEscapedString()); data.putExtra(EXTRA_SELECT_MULTIPLE, false); copy(request, data); setResult(RESULT_OK, data); @@ -401,7 +401,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity im data.putExtra("contact", item.getJid().toString()); String account = request.getStringExtra(EXTRA_ACCOUNT); if (account == null && item instanceof Contact) { - account = ((Contact) item).getAccount().getJid().asBareJid().toString(); + account = ((Contact) item).getAccount().getJid().asBareJid().toEscapedString(); } data.putExtra(EXTRA_ACCOUNT, account); data.putExtra(EXTRA_SELECT_MULTIPLE, false); diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index caeb1e6e2..15190d08c 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -188,11 +188,11 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp showInactiveOmemo = savedInstanceState != null && savedInstanceState.getBoolean("show_inactive_omemo", false); if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) { try { - this.accountJid = Jid.of(getIntent().getExtras().getString(EXTRA_ACCOUNT)); + this.accountJid = Jid.ofEscaped(getIntent().getExtras().getString(EXTRA_ACCOUNT)); } catch (final IllegalArgumentException ignored) { } try { - this.contactJid = Jid.of(getIntent().getExtras().getString("contact")); + this.contactJid = Jid.ofEscaped(getIntent().getExtras().getString("contact")); } catch (final IllegalArgumentException ignored) { } } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 9dd3b0153..b95313ab3 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -772,7 +772,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke contacts[i] = targets.get(i).toString(); } intent.putExtra("contacts", contacts); - intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toString()); + intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toEscapedString()); intent.putExtra("conversation", conversation.getUuid()); startActivityForResult(intent, requestCode); return true; diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 89de15d0b..ebf4c15e0 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -121,7 +121,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat public void onClick(final View view) { if (mAccount != null) { final Intent intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class); - intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toString()); + intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toEscapedString()); startActivity(intent); } } @@ -445,7 +445,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toEscapedString()); } else { intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class); - intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toString()); + intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toEscapedString()); intent.putExtra("setup", true); } if (wasFirstAccount) { @@ -693,7 +693,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat recreate(); } else if (intent != null) { try { - this.jidToEdit = Jid.of(intent.getStringExtra("jid")); + this.jidToEdit = Jid.ofEscaped(intent.getStringExtra("jid")); } catch (final IllegalArgumentException | NullPointerException ignored) { this.jidToEdit = null; } @@ -754,7 +754,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat @Override public void onSaveInstanceState(final Bundle savedInstanceState) { if (mAccount != null) { - savedInstanceState.putString("account", mAccount.getJid().asBareJid().toString()); + savedInstanceState.putString("account", mAccount.getJid().asBareJid().toEscapedString()); savedInstanceState.putBoolean("initMode", mInitMode); savedInstanceState.putBoolean("showMoreTable", binding.serverInfoMore.getVisibility() == View.VISIBLE); } @@ -765,7 +765,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat boolean init = true; if (mSavedInstanceAccount != null) { try { - this.mAccount = xmppConnectionService.findAccountByJid(Jid.of(mSavedInstanceAccount)); + this.mAccount = xmppConnectionService.findAccountByJid(Jid.ofEscaped(mSavedInstanceAccount)); this.mInitMode = mSavedInstanceInit; init = false; } catch (IllegalArgumentException e) { @@ -833,7 +833,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat break; case R.id.action_show_block_list: final Intent showBlocklistIntent = new Intent(this, BlocklistActivity.class); - showBlocklistIntent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().toString()); + showBlocklistIntent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().toEscapedString()); startActivity(showBlocklistIntent); break; case R.id.action_server_info_show_more: @@ -882,7 +882,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat private void gotoChangePassword(String newPassword) { final Intent changePasswordIntent = new Intent(this, ChangePasswordActivity.class); - changePasswordIntent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().toString()); + changePasswordIntent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().toEscapedString()); if (newPassword != null) { changePasswordIntent.putExtra("password", newPassword); } diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java index 6446f5db6..3589bb41e 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java @@ -165,7 +165,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer final Conversation conversation; Account account; try { - account = xmppConnectionService.findAccountByJid(Jid.of(share.account)); + account = xmppConnectionService.findAccountByJid(Jid.ofEscaped(share.account)); } catch (final IllegalArgumentException e) { account = null; } diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 57cc492e0..4d31d74d6 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -1000,7 +1000,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne intent.putExtra(ChooseContactActivity.EXTRA_SHOW_ENTER_JID, false); intent.putExtra(ChooseContactActivity.EXTRA_SELECT_MULTIPLE, true); intent.putExtra(ChooseContactActivity.EXTRA_GROUP_CHAT_NAME, name.trim()); - intent.putExtra(ChooseContactActivity.EXTRA_ACCOUNT, account.getJid().asBareJid().toString()); + intent.putExtra(ChooseContactActivity.EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString()); intent.putExtra(ChooseContactActivity.EXTRA_TITLE_RES_ID, R.string.choose_participants); startActivityForResult(intent, REQUEST_CREATE_CONFERENCE); } diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 887d3374b..93196a8b0 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -522,8 +522,8 @@ public abstract class XmppActivity extends ActionBarActivity { public void switchToContactDetails(Contact contact, String messageFingerprint) { Intent intent = new Intent(this, ContactDetailsActivity.class); intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT); - intent.putExtra(EXTRA_ACCOUNT, contact.getAccount().getJid().asBareJid().toString()); - intent.putExtra("contact", contact.getJid().toString()); + intent.putExtra(EXTRA_ACCOUNT, contact.getAccount().getJid().asBareJid().toEscapedString()); + intent.putExtra("contact", contact.getJid().toEscapedString()); intent.putExtra("fingerprint", messageFingerprint); startActivity(intent); } @@ -538,7 +538,7 @@ public abstract class XmppActivity extends ActionBarActivity { public void switchToAccount(Account account, boolean init, String fingerprint) { Intent intent = new Intent(this, EditAccountActivity.class); - intent.putExtra("jid", account.getJid().asBareJid().toString()); + intent.putExtra("jid", account.getJid().asBareJid().toEscapedString()); intent.putExtra("init", init); if (init) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);