Skip to content

Commit b21d3ed

Browse files
authored
Merge pull request #49 from LeanBitLab/fix-implicit-intent-vulnerability-11572267991238799803
🔒 Secure web intents using Custom Tabs
2 parents 54491f5 + 4ca2487 commit b21d3ed

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ dependencies {
6969
implementation("androidx.core:core-ktx:1.15.0")
7070
implementation("androidx.appcompat:appcompat:1.7.0")
7171
implementation("com.google.android.material:material:1.12.0")
72+
implementation("androidx.browser:browser:1.8.0")
7273
implementation("androidx.work:work-runtime-ktx:2.10.0")
7374
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
7475

app/src/main/java/com/leanbitlab/lwidget/MainActivity.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import android.appwidget.AppWidgetManager
2222
import android.content.ComponentName
2323
import android.content.Context
2424
import android.content.Intent
25+
import androidx.browser.customtabs.CustomTabsIntent
2526
import android.content.SharedPreferences
2627
import android.content.pm.PackageManager
2728
import android.os.Bundle
@@ -121,13 +122,11 @@ class MainActivity : AppCompatActivity() {
121122
tvVersion.text = getString(R.string.changelog_version, versionName)
122123

123124
findViewById<View>(R.id.tv_github_link).setOnClickListener {
124-
val intent = Intent(Intent.ACTION_VIEW, android.net.Uri.parse("https://github.com/LeanBitLab/Lwidget"))
125-
startActivity(intent)
125+
CustomTabsIntent.Builder().build().launchUrl(this@MainActivity, android.net.Uri.parse("https://github.com/LeanBitLab/Lwidget"))
126126
}
127127

128128
findViewById<View>(R.id.tv_privacy_policy).setOnClickListener {
129-
val intent = Intent(Intent.ACTION_VIEW, android.net.Uri.parse("https://github.com/LeanBitLab/Lwidget/wiki/Privacy-Policy"))
130-
startActivity(intent)
129+
CustomTabsIntent.Builder().build().launchUrl(this@MainActivity, android.net.Uri.parse("https://github.com/LeanBitLab/Lwidget/wiki/Privacy-Policy"))
131130
}
132131

133132

@@ -283,7 +282,7 @@ class MainActivity : AppCompatActivity() {
283282
startActivity(Intent(Intent.ACTION_VIEW, android.net.Uri.parse("market://details?id=org.breezyweather")))
284283
} catch (e: Exception) {
285284
try {
286-
startActivity(Intent(Intent.ACTION_VIEW, android.net.Uri.parse("https://f-droid.org/packages/org.breezyweather/")))
285+
CustomTabsIntent.Builder().build().launchUrl(this@MainActivity, android.net.Uri.parse("https://f-droid.org/packages/org.breezyweather/"))
287286
} catch (e2: Exception) {}
288287
}
289288
} else if (weatherMissing) {
@@ -953,7 +952,7 @@ class MainActivity : AppCompatActivity() {
953952
com.google.android.material.snackbar.Snackbar.LENGTH_LONG
954953
).setAction("Install") {
955954
try {
956-
startActivity(Intent(Intent.ACTION_VIEW, android.net.Uri.parse("https://github.com/breezy-weather/breezy-weather/releases")))
955+
CustomTabsIntent.Builder().build().launchUrl(this@MainActivity, android.net.Uri.parse("https://github.com/breezy-weather/breezy-weather/releases"))
957956
} catch (e: Exception) {}
958957
}.show()
959958
return@setOnCheckedChangeListener
@@ -1219,7 +1218,7 @@ class MainActivity : AppCompatActivity() {
12191218
try {
12201219
startActivity(Intent(Intent.ACTION_VIEW, android.net.Uri.parse("market://details?id=org.tasks")))
12211220
} catch (e: Exception) {
1222-
startActivity(Intent(Intent.ACTION_VIEW, android.net.Uri.parse("https://play.google.com/store/apps/details?id=org.tasks")))
1221+
CustomTabsIntent.Builder().build().launchUrl(this@MainActivity, android.net.Uri.parse("https://play.google.com/store/apps/details?id=org.tasks"))
12231222
}
12241223
}.show()
12251224
return@setOnCheckedChangeListener

0 commit comments

Comments
 (0)