Skip to content

Commit

Permalink
UP: Remove sensitive information from endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
p1gp1g committed Sep 14, 2021
1 parent 4c4bffd commit e4bb12d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions vector/src/main/java/im/vector/app/core/pushers/UPHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import im.vector.app.push.fcm.FcmHelper
import org.unifiedpush.android.connector.Registration
import timber.log.Timber
import java.net.URI
import java.net.URL

/**
* This class store the UnifiedPush Endpoint in SharedPrefs and ensure this token is retrieved.
Expand Down Expand Up @@ -177,4 +178,16 @@ object UPHelper {
val up = Registration()
return up.getDistributor(context) == context.packageName
}

fun getPrivacyFriendlyUpEndpoint(context: Context): String? {
val endpoint = getUpEndpoint(context)
if (endpoint.isNullOrEmpty()) return endpoint
return try {
val parsed = URL(endpoint)
"${parsed.protocol}://${parsed.host}"
} catch (e: Exception) {
Timber.e("Error parsing unifiedpush endpoint: $e")
null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class TestNewEndpoint @Inject constructor(private val context: AppCompatActivity
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
status = TestStatus.RUNNING

val endpoint = UPHelper.getUpEndpoint(context)
// Troubleshooters might send a screenshot of this, so use endpoint without token information
val endpoint = UPHelper.getPrivacyFriendlyUpEndpoint(context)

if (UPHelper.isEmbeddedDistributor(context)) {
if (!endpoint.isNullOrEmpty()) {
Expand Down

0 comments on commit e4bb12d

Please sign in to comment.