Skip to content

Commit

Permalink
B64-encode documentId in routes.
Browse files Browse the repository at this point in the history
Some document IDs are URLs, so they have slashes in them. That messes with
our route strings, which use slashes to separate parameters. Encoding the
docId fixes a crash when trying to navigate to the Activity Log for a single
event, when using the German or EU PIDs.

Tested by:
- Manual testing of Utopia, German, and EU PIDs.
- ./gradlew check
- ./gradlew connectedCheck

Signed-off-by: Kevin Deus <[email protected]>
  • Loading branch information
kdeus committed Nov 26, 2024
1 parent 264c00f commit 975309e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.android.identity.util.fromBase64Url
import com.android.identity_credential.wallet.DocumentModel
import com.android.identity_credential.wallet.PermissionTracker
import com.android.identity_credential.wallet.ProvisioningViewModel
Expand Down Expand Up @@ -134,7 +135,8 @@ fun WalletNavigation(
)
) { backStackEntry ->
// Extract arguments from the back stack entry
val documentId = backStackEntry.arguments?.getString("documentId") ?: ""
val encodedDocumentId = backStackEntry.arguments?.getString("documentId") ?: ""
val documentId = String(encodedDocumentId.fromBase64Url())
val timestamp = backStackEntry.arguments?.getString("timestamp") ?: ""

EventDetailsScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.runtime.remember
import androidx.navigation.NavHostController
import com.android.identity.util.toBase64Url
import com.android.identity_credential.wallet.DocumentModel
import com.android.identity_credential.wallet.EventInfo
import com.android.identity_credential.wallet.R
Expand Down Expand Up @@ -110,7 +111,8 @@ fun EventLogScreen(
.padding(4.dp)
.clickable {
// Pass documentId and timestamp as arguments
navController.navigate("${WalletDestination.EventDetails.route}/$documentId/${eventInfo.timestamp}")
val encodedDocId = documentId.toByteArray().toBase64Url()
navController.navigate("${WalletDestination.EventDetails.route}/$encodedDocId/${eventInfo.timestamp}")
},
verticalAlignment = Alignment.CenterVertically
) {
Expand Down

0 comments on commit 975309e

Please sign in to comment.