Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e48e577

Browse files
Preventing FreeOTPPlus to share token to itself
1 parent 5b8e4ea commit e48e577

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

‎app/src/main/java/org/fedorahosted/freeotp/ui/MainActivity.kt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ class MainActivity : AppCompatActivity() {
278278
override fun onNewIntent(intent: Intent) {
279279
super.onNewIntent(intent)
280280

281+
if (packageName == intent.extras?.getString(SHARE_FROM_PACKAGE_NAME_INTENT_EXTRA)) {
282+
Log.i(TAG, "Intent shared from the same package name. Ignoring the intent and do not add the token")
283+
return
284+
}
285+
281286
val uri = intent.data
282287
if (uri != null) {
283288
lifecycleScope.launch {
@@ -460,5 +465,6 @@ class MainActivity : AppCompatActivity() {
460465
const val READ_KEY_URI_REQUEST_CODE = 44
461466
const val WRITE_KEY_URI_REQUEST_CODE = 45
462467
const val SCREENSHOT_MODE_EXTRA = "screenshot_mode"
468+
const val SHARE_FROM_PACKAGE_NAME_INTENT_EXTRA = "shareFromPackageName"
463469
}
464470
}

‎app/src/main/java/org/fedorahosted/freeotp/ui/TokenViewHolder.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class TokenViewHolder(private val activity: Activity,
3232

3333
R.id.action_share -> {
3434
val i = Intent(Intent.ACTION_VIEW, Uri.parse(OtpTokenFactory.toUri(token).toString()))
35+
i.putExtra(MainActivity.SHARE_FROM_PACKAGE_NAME_INTENT_EXTRA, activity.packageName)
3536
activity.startActivity(Intent.createChooser(i, null))
3637
}
3738

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /