mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-18 04:50:08 +03:00
Hide private endpoint data from troubleshooting screen
Change-Id: I406178b5e804bef1aa4e91700a80977be487e0e0
This commit is contained in:
parent
1f64afd6bc
commit
9211d3c4d9
3 changed files with 16 additions and 14 deletions
|
@ -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.
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.content.Context
|
|||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.os.Build
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
|
@ -57,7 +56,6 @@ import java.io.File
|
|||
import java.io.IOException
|
||||
import java.io.OutputStreamWriter
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.util.Locale
|
||||
import java.util.zip.GZIPOutputStream
|
||||
import javax.inject.Inject
|
||||
|
@ -281,7 +279,7 @@ class BugReporter @Inject constructor(
|
|||
|
||||
// UnifiedPush
|
||||
// Only include the UP endpoint base url to exclude private user tokens in the path or parameters
|
||||
builder.addFormDataPart("unifiedpush_endpoint", strippedUrl(UPHelper.getUpEndpoint(context)).toString())
|
||||
builder.addFormDataPart("unifiedpush_endpoint", UPHelper.getPrivacyFriendlyUpEndpoint(context).toString())
|
||||
.addFormDataPart("unifiedpush_gateway", UPHelper.getPushGateway(context))
|
||||
.addFormDataPart("unifiedpush_distributor_exists", UPHelper.distributorExists(context).toString())
|
||||
.addFormDataPart("unifiedpush_is_embedded_distributor", UPHelper.isEmbeddedDistributor(context).toString())
|
||||
|
@ -464,16 +462,6 @@ class BugReporter @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun strippedUrl(url: String?): String? {
|
||||
if (TextUtils.isEmpty(url)) return null
|
||||
return try {
|
||||
val parsed = URL(url)
|
||||
"${parsed.protocol}://${parsed.host}"
|
||||
} catch (e: Exception) {
|
||||
"Malformed url"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a bug report either with email or with Vector.
|
||||
*/
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue