scanned results are always a trusted source

This commit is contained in:
Daniel Gultsch 2018-03-13 16:55:25 +01:00
parent 0c58e7cc30
commit f21fda1421
2 changed files with 14 additions and 9 deletions

View File

@ -273,7 +273,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
try {
Jid jid = Jid.of(searchString);
if (jid.getLocal() != null && jid.isBareJid() && jid.getDomain().contains(".")) {
showCreateContactDialog(jid.toString(),null);
showCreateContactDialog(jid.toString(), null);
return;
}
} catch (IllegalArgumentException ignored) {
@ -475,7 +475,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
} else if (contact.showInRoster()) {
throw new EnterJidDialog.JidError(getString(R.string.contact_already_exists));
} else {
xmppConnectionService.createContact(contact,true);
xmppConnectionService.createContact(contact, true);
if (invite != null && invite.hasFingerprints()) {
xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints());
}
@ -494,7 +494,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
final View dialogView = getLayoutInflater().inflate(R.layout.join_conference_dialog, null);
final Spinner spinner = dialogView.findViewById(R.id.account);
final AutoCompleteTextView jid = dialogView.findViewById(R.id.jid);
DelayedHintHelper.setHint(R.string.conference_address_example,jid);
DelayedHintHelper.setHint(R.string.conference_address_example, jid);
jid.setAdapter(new KnownHostsAdapter(this, R.layout.simple_list_item, mKnownConferenceHosts));
if (prefilledJid != null) {
jid.append(prefilledJid);
@ -752,7 +752,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
if (grantResults.length > 0)
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
ScanActivity.onRequestPermissionResult(this,requestCode,grantResults);
ScanActivity.onRequestPermissionResult(this, requestCode, grantResults);
if (requestCode == REQUEST_SYNC_CONTACTS && xmppConnectionServiceBound) {
xmppConnectionService.loadPhoneContacts();
}
@ -821,7 +821,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
case Intent.ACTION_VIEW:
Uri uri = intent.getData();
if (uri != null) {
Invite invite = new Invite(intent.getData(), false);
Invite invite = new Invite(intent.getData(), intent.getBooleanExtra("scanned", false));
invite.account = intent.getStringExtra("account");
return invite.invite();
} else {

View File

@ -53,7 +53,7 @@ public class UriHandlerActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.handled = savedInstanceState != null && savedInstanceState.getBoolean("handled",false);
this.handled = savedInstanceState != null && savedInstanceState.getBoolean("handled", false);
}
@Override
@ -74,6 +74,10 @@ public class UriHandlerActivity extends AppCompatActivity {
}
private void handleUri(Uri uri) {
handleUri(uri, false);
}
private void handleUri(Uri uri, final boolean scanned) {
final Intent intent;
final XmppUri xmppUri = new XmppUri(uri);
final List<Jid> accounts = DatabaseBackend.getInstance(this).getAccountJids(); //TODO only look at enabled accounts
@ -104,13 +108,14 @@ public class UriHandlerActivity extends AppCompatActivity {
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra("jid", xmppUri.getJid().asBareJid().toString());
intent.setData(uri);
} else if (xmppUri.isJidValid()){
} else if (xmppUri.isJidValid()) {
intent = new Intent(getApplicationContext(), StartConversationActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.putExtra("scanned", scanned);
intent.setData(uri);
} else {
Toast.makeText(this,R.string.invalid_jid,Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.invalid_jid, Toast.LENGTH_SHORT).show();
return;
}
@ -149,7 +154,7 @@ public class UriHandlerActivity extends AppCompatActivity {
String result = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
if (result != null) {
Uri uri = Uri.parse(result);
handleUri(uri);
handleUri(uri, true);
}
}
finish();